This commit is contained in:
@@ -258,6 +258,36 @@ namespace AyaNova.Api.Controllers
|
||||
return Ok(ApiOkResponse.Response(o));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Put (update) part cost for part
|
||||
/// </summary>
|
||||
/// <param name="newCost">new cost of part</param>
|
||||
///<param name="id">PartId</param>
|
||||
/// <returns></returns>
|
||||
[HttpPut("part-cost/{id}")]
|
||||
public async Task<IActionResult> PutPartSerials([FromRoute] long id, [FromBody] decimal newCost)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
PartBiz biz = PartBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
|
||||
var o = await biz.PutPartCostAsync(id, newCost);
|
||||
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(o));
|
||||
}
|
||||
|
||||
|
||||
//------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user