Refactor LeaveBeginningController to restore profile checks and reset leave days to zero
This commit is contained in:
parent
7d3ec6c74e
commit
de91fd0fa2
1 changed files with 19 additions and 19 deletions
|
|
@ -504,11 +504,11 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
// var profile = await _userProfileRepository.GetProfileByProfileIdNoAuthAsync(req.ProfileId, AccessToken);
|
||||
// if(profile == null)
|
||||
// {
|
||||
// return Error("ไม่พบข้อมูลข้าราชการหรือลูกจ้าง", StatusCodes.Status404NotFound);
|
||||
// }
|
||||
var profile = await _userProfileRepository.GetProfileByProfileIdNoAuthAsync(req.ProfileId, AccessToken);
|
||||
if(profile == null)
|
||||
{
|
||||
return Error("ไม่พบข้อมูลข้าราชการหรือลูกจ้าง", StatusCodes.Status404NotFound);
|
||||
}
|
||||
// check duplicate
|
||||
var oldData = await _context.LeaveBeginnings.FirstOrDefaultAsync(x => x.ProfileId == req.ProfileId
|
||||
&& x.LeaveTypeId == req.LeaveTypeId
|
||||
|
|
@ -525,15 +525,15 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
// oldData.BeginningLeaveDays = req.BeginningLeaveDays;
|
||||
// oldData.BeginningLeaveCount = req.BeginningLeaveCount;
|
||||
|
||||
// oldData.ProfileId = req.ProfileId;
|
||||
// oldData.Prefix = profile.Prefix;
|
||||
// oldData.FirstName = profile.FirstName;
|
||||
// oldData.LastName = profile.LastName;
|
||||
// oldData.RootDnaId = profile.RootDnaId;
|
||||
// oldData.Child1DnaId = profile.Child1DnaId;
|
||||
// oldData.Child2DnaId = profile.Child2DnaId;
|
||||
// oldData.Child3DnaId = profile.Child3DnaId;
|
||||
// oldData.Child4DnaId = profile.Child4DnaId;
|
||||
oldData.ProfileId = req.ProfileId;
|
||||
oldData.Prefix = profile.Prefix;
|
||||
oldData.FirstName = profile.FirstName;
|
||||
oldData.LastName = profile.LastName;
|
||||
oldData.RootDnaId = profile.RootDnaId;
|
||||
oldData.Child1DnaId = profile.Child1DnaId;
|
||||
oldData.Child2DnaId = profile.Child2DnaId;
|
||||
oldData.Child3DnaId = profile.Child3DnaId;
|
||||
oldData.Child4DnaId = profile.Child4DnaId;
|
||||
|
||||
oldData.LastUpdateUserId = "";
|
||||
oldData.LastUpdateFullName = "System";
|
||||
|
|
@ -547,10 +547,10 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
leaveBeginning.LeaveTypeId = req.LeaveTypeId;
|
||||
leaveBeginning.LeaveYear = req.LeaveYear;
|
||||
leaveBeginning.LeaveDays = req.LeaveDays;
|
||||
leaveBeginning.LeaveDaysUsed = req.LeaveDaysUsed;
|
||||
leaveBeginning.LeaveCount = req.LeaveCount;
|
||||
leaveBeginning.BeginningLeaveDays = req.BeginningLeaveDays;
|
||||
leaveBeginning.BeginningLeaveCount = req.BeginningLeaveCount;
|
||||
leaveBeginning.LeaveDaysUsed = 0;
|
||||
leaveBeginning.LeaveCount = 0;
|
||||
leaveBeginning.BeginningLeaveDays = 0;
|
||||
leaveBeginning.BeginningLeaveCount = 0;
|
||||
|
||||
leaveBeginning.ProfileId = req.ProfileId;
|
||||
leaveBeginning.Prefix = profile.Prefix;
|
||||
|
|
@ -564,7 +564,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
leaveBeginning.Child4DnaId = profile.Child4DnaId;
|
||||
|
||||
leaveBeginning.CreatedUserId = "";
|
||||
leaveBeginning.CreatedFullName = FullName ?? "";
|
||||
leaveBeginning.CreatedFullName = "System";
|
||||
leaveBeginning.CreatedAt = DateTime.Now;
|
||||
|
||||
await _leaveBeginningRepository.AddAsync(leaveBeginning);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue