This commit is contained in:
@@ -117,7 +117,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
var o = await biz.WorkOrderGetAsync(id);
|
var o = await biz.WorkOrderGetAsync(id, true);
|
||||||
if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||||
return Ok(ApiOkResponse.Response(o));
|
return Ok(ApiOkResponse.Response(o));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ namespace AyaNova.Biz
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// GET
|
// GET
|
||||||
//
|
//
|
||||||
internal async Task<WorkOrder> WorkOrderGetAsync(long id, bool logTheGetEvent = true)
|
internal async Task<WorkOrder> WorkOrderGetAsync(long id, bool populateDisplayFields, bool logTheGetEvent = true)
|
||||||
{
|
{
|
||||||
//Note: there could be rules checking here in future, i.e. can only get own workorder or something
|
//Note: there could be rules checking here in future, i.e. can only get own workorder or something
|
||||||
//if so, then need to implement AddError and in route handle Null return with Error check just like PUT route does now
|
//if so, then need to implement AddError and in route handle Null return with Error check just like PUT route does now
|
||||||
@@ -180,6 +180,8 @@ namespace AyaNova.Biz
|
|||||||
ret.IsLockedAtServer = stat.Locked;
|
ret.IsLockedAtServer = stat.Locked;
|
||||||
ret.IsDirty = false;
|
ret.IsDirty = false;
|
||||||
|
|
||||||
|
if (populateDisplayFields)
|
||||||
|
await WorkOrderPopulateVizFields(ret);
|
||||||
|
|
||||||
if (logTheGetEvent && ret != null)
|
if (logTheGetEvent && ret != null)
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Retrieved), ct);
|
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Retrieved), ct);
|
||||||
@@ -763,7 +765,9 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
private async Task StatePopulateVizFields(WorkOrderState o)
|
private async Task StatePopulateVizFields(WorkOrderState o)
|
||||||
{
|
{
|
||||||
await Task.CompletedTask;
|
|
||||||
|
o.UserViz = await ct.User.AsNoTracking().Where(x => x.Id == o.UserId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||||
|
// await Task.CompletedTask;
|
||||||
// if (o.WorkOrderOverseerId != null)
|
// if (o.WorkOrderOverseerId != null)
|
||||||
// o.WorkOrderOverseerViz = await ct.User.AsNoTracking().Where(x => x.Id == o.WorkOrderOverseerId).Select(x => x.Name).FirstOrDefaultAsync();
|
// o.WorkOrderOverseerViz = await ct.User.AsNoTracking().Where(x => x.Id == o.WorkOrderOverseerId).Select(x => x.Name).FirstOrDefaultAsync();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,9 +15,13 @@ namespace AyaNova.Models
|
|||||||
public long WorkOrderId { get; set; }
|
public long WorkOrderId { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public long WorkOrderStatusId { get; set; }
|
public long WorkOrderStatusId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public DateTime Created { get; set; } = DateTime.UtcNow;
|
public DateTime Created { get; set; } = DateTime.UtcNow;
|
||||||
[Required]
|
[Required]
|
||||||
public long UserId { get; set; }
|
public long UserId { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
public string UserViz { get; set; }
|
||||||
|
|
||||||
//UTILITY FIELDS
|
//UTILITY FIELDS
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
|
|||||||
Reference in New Issue
Block a user