Compare commits
3 commits
1b7bdd82e6
...
d70ed254c0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d70ed254c0 | ||
|
|
de91fd0fa2 | ||
|
|
7d3ec6c74e |
3 changed files with 52 additions and 17 deletions
|
|
@ -500,7 +500,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
[HttpPut("schedule")]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ResponseObject>> ScheduleUpdateLeaveBeginningAsync([FromBody] EditLeaveBeginningDto req)
|
||||
public async Task<ActionResult<ResponseObject>> ScheduleUpdateLeaveBeginningAsync([FromBody] ScheduleEditLeaveBeginningDto req)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -520,10 +520,10 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
oldData.LeaveTypeId = req.LeaveTypeId;
|
||||
oldData.LeaveYear = req.LeaveYear;
|
||||
oldData.LeaveDays = req.LeaveDays;
|
||||
oldData.LeaveDaysUsed = req.LeaveDaysUsed;
|
||||
oldData.LeaveCount = req.LeaveCount;
|
||||
oldData.BeginningLeaveDays = req.BeginningLeaveDays;
|
||||
oldData.BeginningLeaveCount = req.BeginningLeaveCount;
|
||||
// oldData.LeaveDaysUsed = req.LeaveDaysUsed;
|
||||
// oldData.LeaveCount = req.LeaveCount;
|
||||
// oldData.BeginningLeaveDays = req.BeginningLeaveDays;
|
||||
// oldData.BeginningLeaveCount = req.BeginningLeaveCount;
|
||||
|
||||
oldData.ProfileId = req.ProfileId;
|
||||
oldData.Prefix = profile.Prefix;
|
||||
|
|
@ -536,7 +536,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
oldData.Child4DnaId = profile.Child4DnaId;
|
||||
|
||||
oldData.LastUpdateUserId = "";
|
||||
oldData.LastUpdateFullName = FullName ?? "";
|
||||
oldData.LastUpdateFullName = "System";
|
||||
oldData.LastUpdatedAt = DateTime.Now;
|
||||
|
||||
await _leaveBeginningRepository.UpdateAsync(oldData);
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -2323,12 +2323,31 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
await _leaveRequestRepository.SendToOfficerAsync(id);
|
||||
|
||||
// Remove Workflow Integration
|
||||
// var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
// var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
// if (profile == null)
|
||||
// {
|
||||
// return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
// }
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
// Get Officer List
|
||||
var officers = await _userProfileRepository.GetOCStaffAsync(profile.Id, AccessToken);
|
||||
if(officers != null && officers.Count > 0)
|
||||
{
|
||||
foreach (var officer in officers)
|
||||
{
|
||||
// Send Notification
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"มีคำร้องขอลาจาก {profile.Prefix}{profile.FirstName} {profile.LastName} รอรับการอนุมัติจากคุณ",
|
||||
ReceiverUserId = officer.ProfileId,
|
||||
Type = "",
|
||||
Payload = $"{URL}/leave/detail/{id}",
|
||||
};
|
||||
_appDbContext.Set<Notification>().Add(noti);
|
||||
}
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
}
|
||||
// var baseAPIOrg = _configuration["API"];
|
||||
// var apiUrlOrg = $"{baseAPIOrg}/org/workflow/add-workflow";
|
||||
// if (profile.ProfileType == "OFFICER")
|
||||
|
|
|
|||
|
|
@ -29,4 +29,20 @@ namespace BMA.EHR.Leave.Service.DTOs.LeaveBeginnings
|
|||
[Comment("จำนวนครั้งที่ลายกมา")]
|
||||
public int BeginningLeaveCount { get; set; } = 0;
|
||||
}
|
||||
|
||||
|
||||
public class ScheduleEditLeaveBeginningDto
|
||||
{
|
||||
[Required]
|
||||
public Guid ProfileId { get; set; } = Guid.Empty;
|
||||
|
||||
[Required]
|
||||
public Guid LeaveTypeId { get; set; } = Guid.Empty;
|
||||
|
||||
[Required, Comment("ปีงบประมาณ")]
|
||||
public int LeaveYear { get; set; } = 0;
|
||||
|
||||
[Required, Comment("จำนวนวันลายกมา")]
|
||||
public double LeaveDays { get; set; } = 0.0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue