diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index dc64a129..72e942d5 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -2838,6 +2838,69 @@ namespace BMA.EHR.Retirement.Service.Controllers + + /// + /// เพิ่มรายชิื่อผู้อนุมัติ หรือ ผู้บังคับบัญชา + /// + /// + /// + /// เมื่อทำรายการสำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("officer/add-resign/{type}/{id:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> AddApproverCancel(string type, Guid id, [FromBody] List req) + { + try + { + var retirement = await _context.RetirementResignCancels + .Where(x => x.Id == id) + .FirstOrDefaultAsync(); + if (retirement == null) + { + return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + } + + var data = await _context.RetirementResignCancelApprovers + .Where(x => x.RetirementResignCancel.Id == id && x.ApproveType.ToUpper() == type.ToUpper()) + .ToListAsync(); + _context.RemoveRange(data); + + await _context.SaveChangesAsync(); + + var addList = new List(); + + foreach (var r in req) + { + addList.Add(new RetirementResignCancelApprover + { + Seq = r.Seq, + RetirementResignCancel = retirement, + Prefix = r.Prefix, + FirstName = r.FirstName, + LastName = r.LastName, + PositionName = r.PositionName, + ProfileId = r.ProfileId, + KeycloakId = r.KeycloakId, + Org = r.Org, + ApproveStatus = "PENDING", + ApproveType = type.Trim().ToUpper() + }); + } + await _context.AddRangeAsync(addList); + await _context.SaveChangesAsync(); + + return Success(); + + } + catch (Exception ex) + { + return Error(ex); + } + } + /// /// LV2_013 - เจ้าหน้าที่อนุมัติการลา (ADMIN) /// diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignEmployeeController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignEmployeeController.cs index 5a71b856..9094463c 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignEmployeeController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignEmployeeController.cs @@ -2235,6 +2235,69 @@ namespace BMA.EHR.Retirement.Service.Controllers + + /// + /// เพิ่มรายชิื่อผู้อนุมัติ หรือ ผู้บังคับบัญชา + /// + /// + /// + /// เมื่อทำรายการสำเร็จ + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpPost("officer/add-resign/{type}/{id:guid}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] + public async Task> AddApproverCancel(string type, Guid id, [FromBody] List req) + { + try + { + var retirement = await _context.RetirementResignEmployeeCancels + .Where(x => x.Id == id) + .FirstOrDefaultAsync(); + if (retirement == null) + { + return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound); + } + + var data = await _context.RetirementResignEmployeeCancelApprovers + .Where(x => x.RetirementResignEmployeeCancel.Id == id && x.ApproveType.ToUpper() == type.ToUpper()) + .ToListAsync(); + _context.RemoveRange(data); + + await _context.SaveChangesAsync(); + + var addList = new List(); + + foreach (var r in req) + { + addList.Add(new RetirementResignEmployeeCancelApprover + { + Seq = r.Seq, + RetirementResignEmployeeCancel = retirement, + Prefix = r.Prefix, + FirstName = r.FirstName, + LastName = r.LastName, + PositionName = r.PositionName, + ProfileId = r.ProfileId, + KeycloakId = r.KeycloakId, + Org = r.Org, + ApproveStatus = "PENDING", + ApproveType = type.Trim().ToUpper() + }); + } + await _context.AddRangeAsync(addList); + await _context.SaveChangesAsync(); + + return Success(); + + } + catch (Exception ex) + { + return Error(ex); + } + } + /// /// LV2_013 - เจ้าหน้าที่อนุมัติการลา ลูกจ้าง(ADMIN) ///