This commit is contained in:
@@ -139,37 +139,25 @@ namespace AyaNova.Api.Controllers
|
||||
return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
||||
}
|
||||
|
||||
|
||||
//TODO: will need to traverse, don't need it now for PROPOSAL testing so not coding it yet
|
||||
// /// <summary>
|
||||
// /// Delete WorkOrder
|
||||
// /// </summary>
|
||||
// /// <param name="id"></param>
|
||||
// /// <returns>Ok</returns>
|
||||
// [HttpDelete("{id}")]
|
||||
// public async Task<IActionResult> DeleteWorkOrder([FromRoute] long id)
|
||||
// {
|
||||
// if (!serverState.IsOpen)
|
||||
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
|
||||
// if (!ModelState.IsValid)
|
||||
// return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
// //Instantiate the business object handler
|
||||
// WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
|
||||
// var o = await biz.GetAsync(id, false);
|
||||
// if (o == null)
|
||||
// return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
|
||||
// if (!Authorized.HasDeleteRole(HttpContext.Items, biz.BizType))
|
||||
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
// if (!await biz.DeleteAsync(o))
|
||||
// return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
|
||||
// return NoContent();
|
||||
// }
|
||||
/// <summary>
|
||||
/// Delete WorkOrder
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>NoContent</returns>
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteWorkOrder([FromRoute] long id)
|
||||
{
|
||||
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.WorkOrder))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!await biz.DeleteAsync(id))
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
#endregion WorkOrderTopLevel routes
|
||||
|
||||
@@ -255,58 +243,25 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// Delete WorkOrderItem
|
||||
// /// </summary>
|
||||
// /// <param name="workOrderItemId"></param>
|
||||
// /// <returns>Ok-no content</returns>
|
||||
// [HttpDelete("items/{WorkOrderItemId}")]
|
||||
// public async Task<IActionResult> DeleteWorkOrderItem([FromRoute] long workOrderItemId)
|
||||
// {
|
||||
// //NOTE: we don't need the workorder id in the route because the workorder item must contain the workorder id anyway
|
||||
|
||||
// //WorkOrder/{woid}/WorkOrderItems <- all workorderitems, post to add new, put to update all as a collection
|
||||
// //WorkOrder/{WorkOrderId}/WorkOrderItems
|
||||
// if (!serverState.IsOpen)
|
||||
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
|
||||
// if (!ModelState.IsValid)
|
||||
// return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
// //Instantiate the business object handler
|
||||
// WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
|
||||
// if (!Authorized.HasDeleteRole(HttpContext.Items, biz.BizType))
|
||||
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
// //*******************************************************************************
|
||||
// //NOTE: I'm thinking there should be no db access in controller
|
||||
// //let the biz object return not found if necessary
|
||||
// //*******************************************************************************
|
||||
|
||||
// // var o = await biz.GetAsync(workOrderId, false);
|
||||
// // if (o == null)
|
||||
// // return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
// // //Make sure the item exists first before getting into it
|
||||
// // if (!o.WorkOrderItems.Exists(m => m.Id == workOrderItemId))
|
||||
// // return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
|
||||
|
||||
|
||||
// //stubbed out for now just to see routes
|
||||
// // if (!await biz.DeleteItemsAsync(o))
|
||||
// // return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
|
||||
// // return NoContent();
|
||||
|
||||
// return StatusCode(501);
|
||||
// }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Delete WorkOrderItem
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>NoContent</returns>
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteWorkOrderItem([FromRoute] long id)
|
||||
{
|
||||
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.WorkOrderItem))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!await biz.ItemDeleteAsync(id))
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
#endregion workorderitem
|
||||
|
||||
@@ -353,7 +308,7 @@ namespace AyaNova.Api.Controllers
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.WorkOrderItemLabor))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
@@ -419,8 +374,6 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region WorkOrderItemPart
|
||||
|
||||
/// <summary>
|
||||
@@ -458,7 +411,7 @@ namespace AyaNova.Api.Controllers
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.WorkOrderItemPart))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
Reference in New Issue
Block a user