This commit is contained in:
@@ -269,52 +269,52 @@ 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
|
||||
// /// <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));
|
||||
// //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));
|
||||
// if (!ModelState.IsValid)
|
||||
// return BadRequest(new ApiErrorResponse(ModelState));
|
||||
|
||||
//Instantiate the business object handler
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
// //Instantiate the business object handler
|
||||
// WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
|
||||
if (!Authorized.HasDeleteRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
// 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
|
||||
//*******************************************************************************
|
||||
// //*******************************************************************************
|
||||
// //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));
|
||||
// // 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));
|
||||
// //stubbed out for now just to see routes
|
||||
// // if (!await biz.DeleteItemsAsync(o))
|
||||
// // return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
|
||||
// return NoContent();
|
||||
// // return NoContent();
|
||||
|
||||
return StatusCode(501);
|
||||
}
|
||||
// return StatusCode(501);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@@ -392,102 +392,6 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Put (update) WorkOrderItemLabor
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="updatedObject"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("items/labors/{WorkOrderItemLaborId}")]
|
||||
public async Task<IActionResult> PutWorkOrderItemLabor([FromRoute] long id, [FromBody] WorkOrderItemLabor updatedObject)
|
||||
{
|
||||
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.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
// try
|
||||
// {
|
||||
// if (!await biz.PutAsync(o, updatedObject))
|
||||
// return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
// }
|
||||
// catch (DbUpdateConcurrencyException)
|
||||
// {
|
||||
// if (!await biz.ExistsAsync(id))
|
||||
// return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
// else
|
||||
// return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
||||
// }
|
||||
// return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
||||
return StatusCode(501);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Delete WorkOrderItemLabor
|
||||
/// </summary>
|
||||
/// <param name="workOrderItemLaborId"></param>
|
||||
/// <returns>Ok-no content</returns>
|
||||
[HttpDelete("items/labors/{WorkOrderItemLaborId}")]
|
||||
public async Task<IActionResult> DeleteWorkOrderItemLabor([FromRoute] long workOrderItemLaborId)
|
||||
{
|
||||
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));
|
||||
|
||||
// //Get WorkOrderItem
|
||||
// var woitem = o.WorkOrderItems.FirstOrDefault(m => m.Id == workOrderItemId);
|
||||
// if (woitem == null)
|
||||
// return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
|
||||
// //Get WorkOrderItemLabor
|
||||
// var woitemlabor = woitem.WorkOrderItemLabors.FirstOrDefault(m => m.Id == workOrderItemLaborId);
|
||||
// if (woitem == null)
|
||||
// return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
|
||||
|
||||
|
||||
|
||||
//stubbed out for now just to see routes
|
||||
// if (!await biz.DeleteWorkOrderItemLaborAsync(woitemlabor))//may need more info, not sure
|
||||
// return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
|
||||
//return NoContent();
|
||||
|
||||
return StatusCode(501);
|
||||
}
|
||||
#endregion WorkOrderItemLabor
|
||||
|
||||
#region WorkOrderItemPart
|
||||
@@ -563,94 +467,6 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Put (update) WorkOrderItemPart
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="updatedObject"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("items/parts/{WorkOrderItemPartId}")]
|
||||
public async Task<IActionResult> PutWorkOrderItemPart([FromRoute] long id, [FromBody] WorkOrderItemPart updatedObject)
|
||||
{
|
||||
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.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
// try
|
||||
// {
|
||||
// if (!await biz.PutAsync(o, updatedObject))
|
||||
// return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
// }
|
||||
// catch (DbUpdateConcurrencyException)
|
||||
// {
|
||||
// if (!await biz.ExistsAsync(id))
|
||||
// return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
// else
|
||||
// return StatusCode(409, new ApiErrorResponse(ApiErrorCode.CONCURRENCY_CONFLICT));
|
||||
// }
|
||||
// return Ok(ApiOkResponse.Response(new { ConcurrencyToken = o.ConcurrencyToken }, true));
|
||||
return StatusCode(501);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Delete WorkOrderItemPart
|
||||
/// </summary>
|
||||
/// <param name="workOrderItemPartId"></param>
|
||||
/// <returns>Ok-no content</returns>
|
||||
[HttpDelete("items/parts/{WorkOrderItemPartId}")]
|
||||
public async Task<IActionResult> DeleteWorkOrderItemPart([FromRoute] long workOrderItemPartId)
|
||||
{
|
||||
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);
|
||||
}
|
||||
#endregion WorkOrderItemPart
|
||||
|
||||
//------------
|
||||
|
||||
Reference in New Issue
Block a user