แก้ไขข้อมูล อกก

This commit is contained in:
Kittapath 2023-09-13 14:56:47 +07:00
parent cfaf90cb01
commit 15d0af2f23
9 changed files with 16453 additions and 13 deletions

View file

@ -167,6 +167,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
Round = x.Round,
Total = x.Total,
TypeReport = x.TypeReport,
Detail = x.Detail,
Json = true,
Document = x.Document == null ? false : true,
})
@ -188,6 +189,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
Round = retire.Round,
Total = retire.RetirementProfiles.Count(),
TypeReport = retire.TypeReport,
Detail = retire.Detail,
Json = false,
Document = retire.Document == null ? false : true,
});
@ -306,6 +308,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
RetirementPeriod = retire,
Round = retire.Round,
TypeReport = retire.TypeReport,
Detail = retire.Detail,
Year = retire.Year,
Type = retire.Type,
Document = retire.Document,
@ -429,7 +432,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
posNoEmployee = x.Profile.PosNoEmployee,
})
.ToListAsync();
return Success(new { retire.Id, retire.CreatedAt, retire.Year, retire.Round, retire.Type, retire.TypeReport, profile = profile_new });
return Success(new { retire.Id, retire.CreatedAt, retire.Year, retire.Round, retire.Type, retire.TypeReport, retire.Detail, profile = profile_new });
}
/// <summary>
@ -464,7 +467,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
var responseTask = client.GetAsync(url);
var results = responseTask.Result;
var filehis = profileHistorys.Document == null ? null : await _documentService.ImagesPath(profileHistorys.Document.Id);
return Success(new { Json = true, profileHistorys.Id, profileHistorys.CreatedAt, profileHistorys.Year, profileHistorys.Round, profileHistorys.Type, profileHistorys.TypeReport, profile = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ProfileJsonRequest>>(results.Content.ReadAsStringAsync().Result), File = filehis });
return Success(new { Json = true, profileHistorys.Id, profileHistorys.CreatedAt, profileHistorys.Year, profileHistorys.Round, profileHistorys.Type, profileHistorys.TypeReport, profileHistorys.Detail, profile = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ProfileJsonRequest>>(results.Content.ReadAsStringAsync().Result), File = filehis });
}
}
var profile_new = await _context.RetirementProfiles
@ -492,7 +495,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
})
.ToListAsync();
var file = retire.Document == null ? null : await _documentService.ImagesPath(retire.Document.Id);
return Success(new { Json = false, retire.Id, retire.CreatedAt, retire.Year, retire.Round, retire.Type, retire.TypeReport, profile = profile_new, File = file });
return Success(new { Json = false, retire.Id, retire.CreatedAt, retire.Year, retire.Round, retire.Type, retire.TypeReport, retire.Detail, profile = profile_new, File = file });
}
/// <summary>
@ -709,7 +712,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
var retire = await _context.RetirementPeriods
.FirstOrDefaultAsync(x => x.Id == retireId);
if (retire == null)
return Error(GlobalMessages.DataNotFound, 404);
return Error(GlobalMessages.RetirementNotFound, 404);
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
{
var file = Request.Form.Files[0];
@ -744,10 +747,40 @@ namespace BMA.EHR.Retirement.Service.Controllers
.Include(x => x.Document)
.FirstOrDefaultAsync(x => x.Id == retireId);
if (retire == null)
return Error(GlobalMessages.DataNotFound, 404);
return Error(GlobalMessages.RetirementNotFound, 404);
if (retire.Document == null)
return Success(false);
return Success(true);
}
/// <summary>
/// แก้ไขข้อความมติ อ.ก.ก.
/// </summary>
/// <param name="retireId">Id ประกาศ</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("detail/{retireId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateDetailRetirement([FromForm] RetirementDetailRequest req, Guid retireId)
{
var retire = await _context.RetirementPeriods
.FirstOrDefaultAsync(x => x.Id == retireId);
if (retire == null)
{
var retireHistory = await _context.RetirementPeriodHistorys
.FirstOrDefaultAsync(x => x.Id == retireId);
if (retireHistory == null)
return Error(GlobalMessages.RetirementNotFound, 404);
retireHistory.Detail = req.Detail;
}
else
{
retire.Detail = req.Detail;
}
await _context.SaveChangesAsync();
return Success(true);
}
}
}