From cf0fec730f4a21b5228e5b5700b3a807fb737a5f Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 19 Mar 2021 15:00:45 +0000 Subject: [PATCH] --- .../Controllers/ServiceRateController.cs | 19 ++++++++++++++++++- server/AyaNova/biz/ServiceRateBiz.cs | 9 ++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/server/AyaNova/Controllers/ServiceRateController.cs b/server/AyaNova/Controllers/ServiceRateController.cs index 5e6d3c73..c8b33af7 100644 --- a/server/AyaNova/Controllers/ServiceRateController.cs +++ b/server/AyaNova/Controllers/ServiceRateController.cs @@ -150,7 +150,24 @@ namespace AyaNova.Api.Controllers } - + /// + /// Get prior rate Units entered + /// + /// list of Units + [HttpGet("prior-unit-list")] + public async Task GetPriorUnits() + { + if (!serverState.IsOpen) + return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); + ServiceRateBiz biz = ServiceRateBiz.GetBiz(ct, HttpContext); + if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType)) + return StatusCode(403, new ApiNotAuthorizedResponse()); + if (!ModelState.IsValid) + return BadRequest(new ApiErrorResponse(ModelState)); + var o = await biz.GetPriorUnitsAsync(); + if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND)); + return Ok(ApiOkResponse.Response(o)); + } //------------ diff --git a/server/AyaNova/biz/ServiceRateBiz.cs b/server/AyaNova/biz/ServiceRateBiz.cs index 6379562f..453f7d97 100644 --- a/server/AyaNova/biz/ServiceRateBiz.cs +++ b/server/AyaNova/biz/ServiceRateBiz.cs @@ -185,7 +185,14 @@ namespace AyaNova.Biz } } - + //////////////////////////////////////////////////////////////////////////////////////////////// + //GET PRIOR UNITS LIST + // + internal async Task> GetPriorUnitsAsync() + { + var ret = await ct.ServiceRate.AsNoTracking().Select(x => x.Unit).Distinct().OrderBy(x => x).ToListAsync(); + return ret; + } //////////////////////////////////////////////////////////////////////////////////////////////// //SEARCH