diff --git a/server/AyaNova/Controllers/CustomerController.cs b/server/AyaNova/Controllers/CustomerController.cs index ea9acfcd..9b3a1198 100644 --- a/server/AyaNova/Controllers/CustomerController.cs +++ b/server/AyaNova/Controllers/CustomerController.cs @@ -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 })); ; } /// @@ -149,7 +151,24 @@ namespace AyaNova.Api.Controllers } - + /// + /// Get any popup / alert notes for this customer + /// + /// + /// Notes or no content + [HttpGet("alert/{id}")] + public async Task GetCustomerAlert([FromRoute] long id) + { + if (!serverState.IsOpen) + return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); + + if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.Customer)) + return StatusCode(403, new ApiNotAuthorizedResponse()); + if (!ModelState.IsValid) + return BadRequest(new ApiErrorResponse(ModelState)); + + return Ok(ApiOkResponse.Response(await ct.Customer.AsNoTracking().Where(x => x.Id == id).Select(x => x.PopUpNotes).FirstOrDefaultAsync())); + } //------------