This commit is contained in:
2021-01-19 18:39:48 +00:00
parent 4e15728207
commit f78ed5e590

View File

@@ -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));
}
/// <summary>
/// Put (update) PartSerials for part
/// </summary>
/// <param name="serials">array of serial numbers to replace existing array of part serials</param>
///<param name="id">PartId</param>
/// <returns></returns>
[HttpPut("serials/{id}")]
public async Task<IActionResult> PutPartSerials([FromRoute] long id, [FromBody] List<string> 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 })); ;
}
//------------