This commit is contained in:
2021-01-19 00:53:49 +00:00
parent 247c600e15
commit 4e15728207
6 changed files with 66 additions and 5 deletions

View File

@@ -4,6 +4,8 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Logging;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using AyaNova.Models;
using AyaNova.Api.ControllerHelpers;
using AyaNova.Biz;
@@ -125,7 +127,7 @@ namespace AyaNova.Api.Controllers
else
return BadRequest(new ApiErrorResponse(biz.Errors));
}
return Ok(ApiOkResponse.Response(new { Concurrency = o.Concurrency }));;
return Ok(ApiOkResponse.Response(new { Concurrency = o.Concurrency })); ;
}
/// <summary>
@@ -150,6 +152,25 @@ namespace AyaNova.Api.Controllers
/// <summary>
/// Get Part serial numbers for part id
/// </summary>
/// <param name="id"></param>
/// <returns>Part</returns>
[HttpGet("serials/{id}")]
public async Task<IActionResult> GetPartSerials([FromRoute] long id)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.Part))
return StatusCode(403, new ApiNotAuthorizedResponse());
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
var o = await ct.PartSerial.AsNoTracking().Where(z => z.PartId == id).OrderBy(z => z.Serial).Select(z => z.Serial).ToListAsync();
// if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
return Ok(ApiOkResponse.Response(o));
}
//------------