This commit is contained in:
2021-09-15 17:14:45 +00:00
parent 69c6035573
commit 247b36fb72

View File

@@ -56,15 +56,24 @@ namespace AyaNova.Api.Controllers
var UserId = UserIdFromContext.Id(HttpContext.Items);
var UType = UserTypeFromContext.Type(HttpContext.Items);
//Adjust query dates to encompass actual view range
DateTime ViewStart = p.Start;
DateTime ViewEnd = p.End;
//this covers the largest possible window that could display due to nearly a week of the last or next month showing
DateTime dtStart = p.Start.AddDays(-6);
DateTime dtEnd = p.End.AddDays(6);
if (p.View == ScheduleView.Month)
{
ViewStart = p.Start.AddDays(-6);
ViewEnd = p.End.AddDays(6);
}
//WORKORDERS
if (p.WorkOrders && (UType == UserType.Service || UType == UserType.ServiceContractor))
{
r.AddRange(await ct.ViewSchedulePersonalWorkOrder.Where(x => x.SchedUserId == UserId && x.StartDate > dtStart && x.StopDate < dtEnd)
//Note: query for *overlapping* ranges, not *contained* entirely in view range
r.AddRange(await ct.ViewSchedulePersonalWorkOrder.Where(x => x.SchedUserId == UserId && ViewStart <= x.StopDate && x.StartDate <= ViewEnd)
.Select(x => MakeWOSchedItem(x, p))
.ToListAsync());
}
@@ -141,7 +150,7 @@ namespace AyaNova.Api.Controllers
public class PersonalScheduleParams
{
public ScheduleView View {get;set;}
public ScheduleView View { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
public PersonalScheduleWorkOrderColorSource ColorSource { get; set; }