From 581ea5edc38f153d4f33b4f0c57a88c004e2208c Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 30 Apr 2021 13:37:32 +0000 Subject: [PATCH] --- .../AyaNova/Controllers/CustomerController.cs | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) 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())); + } //------------