This commit is contained in:
@@ -236,53 +236,53 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Update WorkOrderState
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="updatedObject">WorkOrderState - top level only, no descendants</param>
|
||||
/// <returns>New concurrency token</returns>
|
||||
[HttpPut("states/")]
|
||||
public async Task<IActionResult> PutWorkOrderState([FromBody] WorkOrderState updatedObject)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.WorkOrderStatus))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.StatePutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
return StatusCode(409, new ApiErrorResponse(biz.Errors));
|
||||
else
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
}
|
||||
return Ok(ApiOkResponse.Response(new { Concurrency = o.Concurrency }));
|
||||
}
|
||||
// /// <summary>
|
||||
// /// Update WorkOrderState
|
||||
// ///
|
||||
// /// </summary>
|
||||
// /// <param name="updatedObject">WorkOrderState - top level only, no descendants</param>
|
||||
// /// <returns>New concurrency token</returns>
|
||||
// [HttpPut("states/")]
|
||||
// public async Task<IActionResult> PutWorkOrderState([FromBody] WorkOrderState updatedObject)
|
||||
// {
|
||||
// if (!serverState.IsOpen)
|
||||
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
// if (!ModelState.IsValid)
|
||||
// return BadRequest(new ApiErrorResponse(ModelState));
|
||||
// WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
// if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.WorkOrderStatus))
|
||||
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
// var o = await biz.StatePutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
// if (o == null)
|
||||
// {
|
||||
// if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
// return StatusCode(409, new ApiErrorResponse(biz.Errors));
|
||||
// else
|
||||
// return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
// }
|
||||
// return Ok(ApiOkResponse.Response(new { Concurrency = o.Concurrency }));
|
||||
// }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Delete WorkOrderState
|
||||
/// </summary>
|
||||
/// <param name="WorkOrderStateId"></param>
|
||||
/// <returns>NoContent</returns>
|
||||
[HttpDelete("states/{WorkOrderStateId}")]
|
||||
public async Task<IActionResult> DeleteWorkOrderState([FromRoute] long WorkOrderStateId)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasDeleteRole(HttpContext.Items, AyaType.WorkOrderStatus))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!await biz.StateDeleteAsync(WorkOrderStateId))
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
return NoContent();
|
||||
}
|
||||
// /// <summary>
|
||||
// /// Delete WorkOrderState
|
||||
// /// </summary>
|
||||
// /// <param name="WorkOrderStateId"></param>
|
||||
// /// <returns>NoContent</returns>
|
||||
// [HttpDelete("states/{WorkOrderStateId}")]
|
||||
// public async Task<IActionResult> DeleteWorkOrderState([FromRoute] long WorkOrderStateId)
|
||||
// {
|
||||
// if (!serverState.IsOpen)
|
||||
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
// if (!ModelState.IsValid)
|
||||
// return BadRequest(new ApiErrorResponse(ModelState));
|
||||
// WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
// if (!Authorized.HasDeleteRole(HttpContext.Items, AyaType.WorkOrderStatus))
|
||||
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
// if (!await biz.StateDeleteAsync(WorkOrderStateId))
|
||||
// return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
// return NoContent();
|
||||
// }
|
||||
|
||||
#endregion workorderstate
|
||||
|
||||
|
||||
Reference in New Issue
Block a user