This commit is contained in:
@@ -6,6 +6,8 @@ using Microsoft.AspNetCore.Authorization;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
using AyaNova.Models;
|
using AyaNova.Models;
|
||||||
using AyaNova.Api.ControllerHelpers;
|
using AyaNova.Api.ControllerHelpers;
|
||||||
using AyaNova.Biz;
|
using AyaNova.Biz;
|
||||||
@@ -172,6 +174,34 @@ namespace AyaNova.Api.Controllers
|
|||||||
return Ok(ApiOkResponse.Response(o));
|
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 })); ;
|
||||||
|
}
|
||||||
|
|
||||||
//------------
|
//------------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user