This commit is contained in:
@@ -132,6 +132,57 @@ namespace AyaNova.Api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//###############################################################
|
||||||
|
//USER - svc-schedule-user
|
||||||
|
//###############################################################
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get User schedule for parameters specified
|
||||||
|
/// time zone UTC offset in minutes is required to be passed in
|
||||||
|
/// timestamps returned are in Unix Epoch milliseconds converted for local time display
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="p">User schedule parameters</param>
|
||||||
|
/// <param name="apiVersion">From route path</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("user")]
|
||||||
|
public async Task<IActionResult> PostUserSchedule([FromBody] PersonalScheduleParams p, ApiVersion apiVersion)
|
||||||
|
{
|
||||||
|
if (!serverState.IsOpen)
|
||||||
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
if (!ModelState.IsValid)
|
||||||
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
|
||||||
|
List<PersonalScheduleListItem> r = new List<PersonalScheduleListItem>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Note: query will return records that fall within viewed range even if they start or end outside of it
|
||||||
|
//However in month view (only, rest are as is) we can see up to 6 days before or after the month so in the interest of filling those voids:
|
||||||
|
//Adjust query dates to encompass actual potential 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
|
||||||
|
if (p.View == ScheduleView.Month)
|
||||||
|
{
|
||||||
|
ViewStart = p.Start.AddDays(-6);
|
||||||
|
ViewEnd = p.End.AddDays(6);
|
||||||
|
}
|
||||||
|
|
||||||
|
long? actualUserId = p.UserId == 0 ? null : p.UserId;
|
||||||
|
|
||||||
|
//WORKORDERS
|
||||||
|
{
|
||||||
|
//Note: query for *overlapping* ranges, not *contained* entirely in view range
|
||||||
|
r.AddRange(await ct.ViewScheduleWorkOrder.Where(x => x.SchedUserId == actualUserId && ViewStart <= x.StopDate && x.StartDate <= ViewEnd)
|
||||||
|
.Select(x => MakePersonalWOSchedItem(x, p))
|
||||||
|
.ToListAsync());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return Ok(ApiOkResponse.Response(r));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//###############################################################
|
//###############################################################
|
||||||
//PERSONAL
|
//PERSONAL
|
||||||
//###############################################################
|
//###############################################################
|
||||||
@@ -200,7 +251,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
/// <param name="apiVersion">From route path</param>
|
/// <param name="apiVersion">From route path</param>
|
||||||
/// <returns>Error or OK response</returns>
|
/// <returns>Error or OK response</returns>
|
||||||
[HttpPost("adjust")]
|
[HttpPost("adjust")]
|
||||||
public async Task<IActionResult> PostPersonalSchedule([FromBody] ScheduleItemAdjustParams ad, ApiVersion apiVersion)
|
public async Task<IActionResult> AdjustSchedule([FromBody] ScheduleItemAdjustParams ad, ApiVersion apiVersion)
|
||||||
{
|
{
|
||||||
if (!serverState.IsOpen)
|
if (!serverState.IsOpen)
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
@@ -214,6 +265,10 @@ namespace AyaNova.Api.Controllers
|
|||||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.WorkOrderItemScheduledUser) || biz.UserIsRestrictedType)
|
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.WorkOrderItemScheduledUser) || biz.UserIsRestrictedType)
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
|
//svc-schedule-user uses 0 to mean unassigned user but here it's null
|
||||||
|
//and it can't be a required parameter and provide null for some reason so zero is the token indicator
|
||||||
|
if (ad.UserId == 0)
|
||||||
|
ad.UserId = null;
|
||||||
var o = await biz.ScheduledUserPutNewScheduleTimeAsync(ad);
|
var o = await biz.ScheduledUserPutNewScheduleTimeAsync(ad);
|
||||||
if (o == false)
|
if (o == false)
|
||||||
{
|
{
|
||||||
@@ -396,6 +451,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
public bool Reminders { get; set; }
|
public bool Reminders { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public bool Dark { get; set; }//indicate if Client is set to dark mode or not, used for colorless types to display as black or white
|
public bool Dark { get; set; }//indicate if Client is set to dark mode or not, used for colorless types to display as black or white
|
||||||
|
[Required]
|
||||||
|
public long UserId { get; set; }//required due to dual use from home-schedule and svc-schedule-user if it's a 0 zero then it's actually meant to be null not assigned userid
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PersonalScheduleListItem
|
public class PersonalScheduleListItem
|
||||||
|
|||||||
@@ -546,7 +546,9 @@ namespace AyaNova.DataList
|
|||||||
|
|
||||||
long lId = 0;
|
long lId = 0;
|
||||||
if (!long.TryParse(crit[0], out lId)) return ret;
|
if (!long.TryParse(crit[0], out lId)) return ret;
|
||||||
if (lId == 0) return ret;
|
|
||||||
|
//special exemption if id is zero then it's the unassigned user being requested
|
||||||
|
//if (lId == 0) return ret;
|
||||||
|
|
||||||
//Have valid type, have an id, so filter away
|
//Have valid type, have an id, so filter away
|
||||||
switch (forType)
|
switch (forType)
|
||||||
@@ -554,8 +556,16 @@ namespace AyaNova.DataList
|
|||||||
case AyaType.User:
|
case AyaType.User:
|
||||||
{
|
{
|
||||||
DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metauser" };
|
DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metauser" };
|
||||||
FilterOption.Items.Add(new DataListColumnFilter() { value = crit[0], op = DataListFilterComparisonOperator.Equality });
|
if (lId == 0)
|
||||||
ret.Add(FilterOption);
|
{
|
||||||
|
FilterOption.Items.Add(new DataListColumnFilter() { value = "*NULL*", op = DataListFilterComparisonOperator.Equality });
|
||||||
|
ret.Add(FilterOption);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FilterOption.Items.Add(new DataListColumnFilter() { value = crit[0], op = DataListFilterComparisonOperator.Equality });
|
||||||
|
ret.Add(FilterOption);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user