retirement resign cancel add api add commander
This commit is contained in:
parent
afef4fde9f
commit
513eb223be
2 changed files with 126 additions and 0 deletions
|
|
@ -2838,6 +2838,69 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// เพิ่มรายชิื่อผู้อนุมัติ หรือ ผู้บังคับบัญชา
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("officer/add-resign/{type}/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> AddApproverCancel(string type, Guid id, [FromBody] List<RetirementRequestApproverDto> 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<RetirementResignCancelApprover>();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_013 - เจ้าหน้าที่อนุมัติการลา (ADMIN)
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -2235,6 +2235,69 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// เพิ่มรายชิื่อผู้อนุมัติ หรือ ผู้บังคับบัญชา
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("officer/add-resign/{type}/{id:guid}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> AddApproverCancel(string type, Guid id, [FromBody] List<RetirementRequestApproverDto> 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<RetirementResignEmployeeCancelApprover>();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_013 - เจ้าหน้าที่อนุมัติการลา ลูกจ้าง(ADMIN)
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue