diff --git a/server/AyaNova/Controllers/WorkOrderController.cs b/server/AyaNova/Controllers/WorkOrderController.cs index 0f1a3f6a..83c3d3ee 100644 --- a/server/AyaNova/Controllers/WorkOrderController.cs +++ b/server/AyaNova/Controllers/WorkOrderController.cs @@ -269,52 +269,52 @@ namespace AyaNova.Api.Controllers - /// - /// Delete WorkOrderItem - /// - /// - /// Ok-no content - [HttpDelete("items/{WorkOrderItemId}")] - public async Task 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 + // /// + // /// Delete WorkOrderItem + // /// + // /// + // /// Ok-no content + // [HttpDelete("items/{WorkOrderItemId}")] + // public async Task 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 } - - /// - /// Put (update) WorkOrderItemLabor - /// - /// - /// - /// - [HttpPut("items/labors/{WorkOrderItemLaborId}")] - public async Task 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); - } - - - - - /// - /// Delete WorkOrderItemLabor - /// - /// - /// Ok-no content - [HttpDelete("items/labors/{WorkOrderItemLaborId}")] - public async Task 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 } - - /// - /// Put (update) WorkOrderItemPart - /// - /// - /// - /// - [HttpPut("items/parts/{WorkOrderItemPartId}")] - public async Task 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); - } - - - - - /// - /// Delete WorkOrderItemPart - /// - /// - /// Ok-no content - [HttpDelete("items/parts/{WorkOrderItemPartId}")] - public async Task 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 //------------