This commit is contained in:
@@ -158,10 +158,13 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Put (update) WorkOrder
|
/// Put (update) WorkOrder
|
||||||
|
/// This route does not update the entire WorkOrder object graph, only the top level
|
||||||
|
/// in other words nothing in any descendent child collections such as WorkOrderItems and below.
|
||||||
|
/// Use the separate routes to update descendents of the WorkOrder
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id">WorkOrder id</param>
|
||||||
/// <param name="updatedObject"></param>
|
/// <param name="updatedObject">Workorder top level only, no descendents are evaluated</param>
|
||||||
/// <returns></returns>
|
/// <returns>New concurrency token</returns>
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
public async Task<IActionResult> PutWorkOrder([FromRoute] long id, [FromBody] WorkOrder updatedObject)
|
public async Task<IActionResult> PutWorkOrder([FromRoute] long id, [FromBody] WorkOrder updatedObject)
|
||||||
{
|
{
|
||||||
@@ -178,8 +181,13 @@ namespace AyaNova.Api.Controllers
|
|||||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
|
|
||||||
biz.PutAsync(id, updatedObject);
|
var o = await biz.PutAsync(id, updatedObject);
|
||||||
//todo: handle concurrency in biz object, what to do?
|
if (o == null)
|
||||||
|
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
|
|
||||||
|
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
||||||
|
|
||||||
|
//todo: handle concurrency in biz object, what to do?
|
||||||
|
|
||||||
// var o = await biz.PutAsync(id, updatedObject);
|
// var o = await biz.PutAsync(id, updatedObject);
|
||||||
// try
|
// try
|
||||||
@@ -285,7 +293,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
else
|
else
|
||||||
return CreatedAtAction(nameof(WorkOrderController.GetWorkOrderItem), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
return CreatedAtAction(nameof(WorkOrderController.GetWorkOrderItem), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -152,25 +152,21 @@ namespace AyaNova.Biz
|
|||||||
if (HasErrors)
|
if (HasErrors)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// try
|
try
|
||||||
// {
|
{
|
||||||
// if (o==null)
|
await ct.SaveChangesAsync();
|
||||||
// return BadRequest(new ApiErrorResponse(biz.Errors));
|
}
|
||||||
// }
|
catch (DbUpdateConcurrencyException)
|
||||||
// catch (DbUpdateConcurrencyException)
|
{
|
||||||
// {
|
if (!await WorkOrderExistsAsync(id))
|
||||||
// if (!await biz.ExistsAsync(id))
|
AddError(ApiErrorCode.NOT_FOUND);
|
||||||
// return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
else
|
||||||
// else
|
new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT);
|
||||||
// return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
return null;
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
//Log event and save context
|
|
||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct);
|
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct);
|
||||||
await SearchIndexAsync(dbObject, false);
|
await SearchIndexAsync(dbObject, false);
|
||||||
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags);
|
await TagUtil.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags);
|
||||||
|
|
||||||
return dbObject;
|
return dbObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user