เปลี่ยน Method เส้นอัพเดท mark
This commit is contained in:
parent
de72adc3ae
commit
d0e39e385b
2 changed files with 19 additions and 30 deletions
|
|
@ -3139,58 +3139,35 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
/// <summary>
|
||||
/// อัพเดทสถานะ Mark (โทษทางวินัย, ไม่ได้เลื่อนเงินเดือน/ไม่ได้เลื่อนขั้น (เนื่องจากลาเกิน), ผลการประเมินการปฏิบัติราชการในรอบ 5 ปี, ข้อมูลเครื่องราชฯ)
|
||||
/// </summary>
|
||||
/// <param name="insigniaPeriodId">Id รอบเครื่องราช</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("update/{insigniaPeriodId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> InsigniaRequestUpdateMark(Guid insigniaPeriodId)
|
||||
[HttpPut("update")]
|
||||
public async Task<ActionResult<ResponseObject>> InsigniaRequestUpdateMark([FromBody] UpdateInsigniaRequestProfile req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var insigniaPeriod = await _context.InsigniaPeriods
|
||||
.Include(x => x.InsigniaRequests)
|
||||
.Include(x => x.InsigniaEmployees)
|
||||
.FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
|
||||
.Include(x => x.InsigniaRequests.Where(r => r.OrganizationId == req.agencyId))
|
||||
.FirstOrDefaultAsync(x => x.Id == req.insigniaPeriodId);
|
||||
if (insigniaPeriod == null)
|
||||
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||
|
||||
if (insigniaPeriod.InsigniaRequests.Count > 0)
|
||||
{
|
||||
//var allProfileIds = new List<string>();
|
||||
//var allProfileEmpIds = new List<string>();
|
||||
|
||||
foreach (var InsigniaRequest in insigniaPeriod.InsigniaRequests)
|
||||
{
|
||||
var profiles = await _context.Set<InsigniaRequestProfile>()
|
||||
.Where(p => p.Request.Id == InsigniaRequest.Id && p.ProfileType.Trim().ToUpper() == "OFFICER").Select(x => x.ProfileId.ToString()).ToListAsync();
|
||||
|
||||
var profileEmps = await _context.Set<InsigniaRequestProfile>()
|
||||
.Where(p => p.Request.Id == InsigniaRequest.Id && p.ProfileType.Trim().ToUpper() == "EMPLOYEE").Select(x => x.ProfileId.ToString()).ToListAsync();
|
||||
.Where(p => p.Request.Id == InsigniaRequest.Id && p.ProfileType == req.type.Trim().ToUpper()).Select(x => x.ProfileId.ToString()).ToListAsync();
|
||||
|
||||
if (profiles.Count > 0)
|
||||
{
|
||||
//allProfileIds.AddRange(profiles);
|
||||
await _insigniaPeriodRepository.UpdateInsigniaRequestProfile(profiles.ToArray(), "OFFICER");
|
||||
}
|
||||
|
||||
if (profileEmps.Count > 0)
|
||||
{
|
||||
//allProfileEmpIds.AddRange(profileEmps);
|
||||
await _insigniaPeriodRepository.UpdateInsigniaRequestProfile(profileEmps.ToArray(), "EMPLOYEE");
|
||||
await _insigniaPeriodRepository.UpdateInsigniaRequestProfile(profiles.ToArray(), req.type.Trim().ToUpper());
|
||||
}
|
||||
}
|
||||
|
||||
//if (allProfileIds.Count > 0)
|
||||
//{
|
||||
// await _insigniaPeriodRepository.UpdateInsigniaRequestProfile(allProfileIds.ToArray(), "OFFICER");
|
||||
//}
|
||||
|
||||
//if (allProfileEmpIds.Count > 0)
|
||||
//{
|
||||
// await _insigniaPeriodRepository.UpdateInsigniaRequestProfile(allProfileEmpIds.ToArray(), "EMPLOYEE");
|
||||
//}
|
||||
}
|
||||
|
||||
return Success();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue