From 8d1b37aef7476835d73fa4424bb8e5e055b940d2 Mon Sep 17 00:00:00 2001 From: moss <> Date: Thu, 27 Mar 2025 16:31:40 +0700 Subject: [PATCH] sort retirement --- .../Controllers/RetirementController.cs | 85 ++++++++++--------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs index b3ef4415..7e79365e 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs @@ -561,50 +561,51 @@ namespace BMA.EHR.Retirement.Service.Controllers } var profile_old = await _context.RetirementProfiles .Where(x => x.RetirementPeriod == retire) - .OrderBy(x => rootOrder.ToObject>().IndexOf(x.root)) - .ThenBy(x => posTypeNameOrder.ToObject>().IndexOf(x.posTypeName ?? "")) - .ThenBy(x => posLevelNameOrder.ToObject>().IndexOf(x.posLevelName ?? "")) - .Select((x,index) => new - { - order = retire.TypeReport == null ? index + 1 : x.Order, - id = x.Id, - reason = x.Reason, - remove = x.Remove, - profileId = x.profileId, - prefix = x.prefix, - firstName = x.firstName, - lastName = x.lastName, - citizenId = x.citizenId, - root = x.root, - rootId = x.rootId, - rootShortName = x.rootShortName, - child1 = x.child1, - child1Id = x.child1Id, - child1ShortName = x.child1ShortName, - child2 = x.child2, - child2Id = x.child2Id, - child2ShortName = x.child2ShortName, - child3 = x.child3, - child3Id = x.child3Id, - child3ShortName = x.child3ShortName, - child4 = x.child4, - child4Id = x.child4Id, - child4ShortName = x.child4ShortName, - posMasterNo = x.posMasterNo, - position = x.position, - posTypeId = x.posTypeId, - posTypeName = x.posTypeName, - posTypeRank = x.posTypeRank, - posLevelId = x.posLevelId, - posLevelName = x.posLevelName, - posLevelRank = x.posLevelRank, - posExecutiveId = x.posExecutiveId, - posExecutiveName = x.posExecutiveName, - posNo = x.posNo, - }) .ToListAsync(); + var _profile_old = profile_old + .OrderBy(x => rootOrder.ToObject>().IndexOf(x.root)) + .ThenBy(x => posTypeNameOrder.ToObject>().IndexOf(x.posTypeName ?? "")) + .ThenBy(x => posLevelNameOrder.ToObject>().IndexOf(x.posLevelName ?? "")) + .Select((x,index) => new + { + order = retire.TypeReport == null ? index + 1 : x.Order, + id = x.Id, + reason = x.Reason, + remove = x.Remove, + profileId = x.profileId, + prefix = x.prefix, + firstName = x.firstName, + lastName = x.lastName, + citizenId = x.citizenId, + root = x.root, + rootId = x.rootId, + rootShortName = x.rootShortName, + child1 = x.child1, + child1Id = x.child1Id, + child1ShortName = x.child1ShortName, + child2 = x.child2, + child2Id = x.child2Id, + child2ShortName = x.child2ShortName, + child3 = x.child3, + child3Id = x.child3Id, + child3ShortName = x.child3ShortName, + child4 = x.child4, + child4Id = x.child4Id, + child4ShortName = x.child4ShortName, + posMasterNo = x.posMasterNo, + position = x.position, + posTypeId = x.posTypeId, + posTypeName = x.posTypeName, + posTypeRank = x.posTypeRank, + posLevelId = x.posLevelId, + posLevelName = x.posLevelName, + posLevelRank = x.posLevelRank, + posExecutiveId = x.posExecutiveId, + posExecutiveName = x.posExecutiveName, + posNo = x.posNo, + }); var file_name = $"retire_tmp_{DateTime.Now.ToString("yyyyMMddTHHmmss")}"; - var profile = Newtonsoft.Json.JsonConvert.SerializeObject(profile_old); + var profile = Newtonsoft.Json.JsonConvert.SerializeObject(_profile_old); await _documentService.GenerateJsonFile(profile, "/retire", file_name); var history = new RetirementPeriodHistory {