diff --git a/server/AyaNova/Controllers/PartController.cs b/server/AyaNova/Controllers/PartController.cs index 01af5c37..e4dd639c 100644 --- a/server/AyaNova/Controllers/PartController.cs +++ b/server/AyaNova/Controllers/PartController.cs @@ -6,6 +6,8 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.Extensions.Logging; using Microsoft.EntityFrameworkCore; using System.Linq; +using System.Collections.Generic; +using System; using AyaNova.Models; using AyaNova.Api.ControllerHelpers; using AyaNova.Biz; @@ -172,6 +174,34 @@ namespace AyaNova.Api.Controllers return Ok(ApiOkResponse.Response(o)); } + /// + /// Put (update) PartSerials for part + /// + /// array of serial numbers to replace existing array of part serials + ///PartId + /// + [HttpPut("serials/{id}")] + public async Task PutPartSerials([FromRoute] long id, [FromBody] List serials) + { + 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 v = await ct.SaveChangesAsync(); + return Accepted(); + // var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token + // 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(new { Concurrency = o.Concurrency })); ; + } //------------