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