fix : ต่อ API ระยยลา
This commit is contained in:
parent
66d491a2af
commit
be1c390bb8
10 changed files with 142 additions and 54 deletions
|
|
@ -43,6 +43,8 @@ namespace BMA.EHR.Application.Repositories
|
||||||
|
|
||||||
protected bool? IsPlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
protected bool? IsPlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||||
|
|
||||||
|
protected string? AccessToken => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region " Methods "
|
#region " Methods "
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ namespace BMA.EHR.Application.Repositories.Leaves
|
||||||
|
|
||||||
protected bool? IsPlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
protected bool? IsPlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||||
|
|
||||||
|
protected string? AccessToken => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region " Methods "
|
#region " Methods "
|
||||||
|
|
|
||||||
|
|
@ -259,7 +259,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
throw new Exception(GlobalMessages.DataNotFound);
|
throw new Exception(GlobalMessages.DataNotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken ?? "");
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
throw new Exception(GlobalMessages.DataNotFound);
|
throw new Exception(GlobalMessages.DataNotFound);
|
||||||
|
|
@ -292,7 +292,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
throw new Exception(GlobalMessages.DataNotFound);
|
throw new Exception(GlobalMessages.DataNotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken ?? "");
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
throw new Exception(GlobalMessages.DataNotFound);
|
throw new Exception(GlobalMessages.DataNotFound);
|
||||||
|
|
@ -404,7 +404,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้");
|
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้");
|
||||||
}
|
}
|
||||||
|
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId,AccessToken);
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
throw new Exception(GlobalMessages.DataNotFound);
|
throw new Exception(GlobalMessages.DataNotFound);
|
||||||
|
|
@ -464,7 +464,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้");
|
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้");
|
||||||
}
|
}
|
||||||
|
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
throw new Exception(GlobalMessages.DataNotFound);
|
throw new Exception(GlobalMessages.DataNotFound);
|
||||||
|
|
@ -516,11 +516,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<double> GetSumApproveLeaveByRangeForUser(Guid keycloakUserId,DateTime startDate, DateTime endDate)
|
public async Task<double> GetSumApproveLeaveByRangeForUser(Guid keycloakUserId, DateTime startDate, DateTime endDate)
|
||||||
{
|
{
|
||||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable()
|
var data = await _dbContext.Set<LeaveRequest>().AsQueryable()
|
||||||
.Include(x => x.Type)
|
.Include(x => x.Type)
|
||||||
.Where(x => x.KeycloakUserId == keycloakUserId)
|
.Where(x => x.KeycloakUserId == keycloakUserId)
|
||||||
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
||||||
.Where(x => x.LeaveStatus == "APPROVE")
|
.Where(x => x.LeaveStatus == "APPROVE")
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
||||||
await base.AddAsync(entity);
|
await base.AddAsync(entity);
|
||||||
|
|
||||||
var userId = UserId != null ? Guid.Parse(UserId) : Guid.Empty;
|
var userId = UserId != null ? Guid.Parse(UserId) : Guid.Empty;
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken ?? "");
|
||||||
var profile_id = profile == null ? Guid.Empty : profile.Id;
|
var profile_id = profile == null ? Guid.Empty : profile.Id;
|
||||||
|
|
||||||
var rootOc = _userProfileRepository.GetRootOcId(profile_id);
|
var rootOc = _userProfileRepository.GetRootOcId(profile_id);
|
||||||
|
|
@ -88,7 +88,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
||||||
|
|
||||||
// send inbox and notification
|
// send inbox and notification
|
||||||
var subject_str = $"มีการขออนุมัติลงเวลากรณีพิเศษ";
|
var subject_str = $"มีการขออนุมัติลงเวลากรณีพิเศษ";
|
||||||
var body_str = $"โปรดพิจารณาคำร้องขอลงเวลาในกรณีพิเศษจาก {profile.Prefix.Name}{profile.FirstName} {profile.LastName} ในวันที่ {entity.CheckDate.Date.ToThaiShortDate2()}";
|
var body_str = $"โปรดพิจารณาคำร้องขอลงเวลาในกรณีพิเศษจาก {profile.Prefix}{profile.FirstName} {profile.LastName} ในวันที่ {entity.CheckDate.Date.ToThaiShortDate2()}";
|
||||||
|
|
||||||
var subject = subject_str;
|
var subject = subject_str;
|
||||||
var body = body_str;
|
var body = body_str;
|
||||||
|
|
|
||||||
|
|
@ -61,18 +61,31 @@ namespace BMA.EHR.Application.Repositories
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<Profile?> GetProfileByKeycloakIdAsync(Guid keycloakId)
|
public async Task<GetProfileByKeycloakIdDto?> GetProfileByKeycloakIdAsync(Guid keycloakId, string? accessToken)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var data = await _dbContext.Set<Profile>().AsQueryable()
|
var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak/{keycloakId}";
|
||||||
.Include(p => p.Prefix)
|
|
||||||
.Include(p => p.Position)
|
|
||||||
.Include(p => p.PositionLevel)
|
|
||||||
.Include(p => p.Salaries)
|
|
||||||
.FirstOrDefaultAsync(p => p.KeycloakId == keycloakId);
|
|
||||||
|
|
||||||
return data;
|
|
||||||
|
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "");
|
||||||
|
if (apiResult != null)
|
||||||
|
{
|
||||||
|
var raw = JsonConvert.DeserializeObject<GetProfileByKeycloakIdResultDto>(apiResult);
|
||||||
|
if (raw != null)
|
||||||
|
return raw.Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
//var data = await _dbContext.Set<Profile>().AsQueryable()
|
||||||
|
// .Include(p => p.Prefix)
|
||||||
|
// .Include(p => p.Position)
|
||||||
|
// .Include(p => p.PositionLevel)
|
||||||
|
// .Include(p => p.Salaries)
|
||||||
|
// .FirstOrDefaultAsync(p => p.KeycloakId == keycloakId);
|
||||||
|
|
||||||
|
//return data;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
using BMA.EHR.Domain.Models.HR;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Application.Responses.Profiles
|
||||||
|
{
|
||||||
|
public class GetProfileByKeycloakIdDto
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
public string? Prefix { get; set; }
|
||||||
|
public string? FirstName { get; set; }
|
||||||
|
public string? LastName { get; set; }
|
||||||
|
public string? CitizenId { get; set; }
|
||||||
|
|
||||||
|
public DateTime BirthDate { get; set; } = DateTime.MinValue;
|
||||||
|
|
||||||
|
public DateTime? DateStart { get; set; } = DateTime.MinValue;
|
||||||
|
|
||||||
|
public DateTime? DateAppoint { get; set; } = DateTime.MinValue;
|
||||||
|
|
||||||
|
public string? Position { get; set; }
|
||||||
|
|
||||||
|
public Guid? OcId { get; set; }
|
||||||
|
|
||||||
|
public PosType? PosType { get; set; }
|
||||||
|
|
||||||
|
public PosLevel? PosLevel { get; set; }
|
||||||
|
|
||||||
|
public string? Oc { get; set; }
|
||||||
|
|
||||||
|
public List<ProfileSalary> Salaries { get; set; } = new();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PosLevel
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
public Guid CreatedUserId { get; set; }
|
||||||
|
public DateTime LastUpdatedAt { get; set; }
|
||||||
|
public Guid LastUpdateUserId { get; set; }
|
||||||
|
public string CreatedFullName { get; set; }
|
||||||
|
public string LastUpdateFullName { get; set; }
|
||||||
|
public string PosLevelName { get; set; }
|
||||||
|
public string PosTypeId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PosType
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
public Guid CreatedUserId { get; set; }
|
||||||
|
public DateTime LastUpdatedAt { get; set; }
|
||||||
|
public Guid LastUpdateUserId { get; set; }
|
||||||
|
public string CreatedFullName { get; set; }
|
||||||
|
public string LastUpdateFullName { get; set; }
|
||||||
|
public string PosTypeName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
namespace BMA.EHR.Application.Responses.Profiles
|
||||||
|
{
|
||||||
|
public class GetProfileByKeycloakIdResultDto
|
||||||
|
{
|
||||||
|
public string Message { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Status { get; set; } = -1;
|
||||||
|
|
||||||
|
public GetProfileByKeycloakIdDto? Result { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
{
|
{
|
||||||
public class SearchProfileResultDto
|
public class SearchProfileResultDto
|
||||||
{
|
{
|
||||||
public string Messsage { get; set; } = string.Empty;
|
public string Message { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int Status { get; set; } = -1;
|
public int Status { get; set; } = -1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -421,7 +421,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
public async Task<ActionResult<ResponseObject>> CheckInAsync([FromForm] CheckTimeDto data)
|
public async Task<ActionResult<ResponseObject>> CheckInAsync([FromForm] CheckTimeDto data)
|
||||||
{
|
{
|
||||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||||
|
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
|
|
@ -583,7 +583,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||||
|
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
|
|
@ -751,7 +751,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(d.KeycloakUserId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(d.KeycloakUserId, AccessToken);
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
|
|
@ -844,7 +844,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||||
|
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
|
|
@ -973,7 +973,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
ProfileId = p.Id,
|
ProfileId = p.Id,
|
||||||
CitizenId = p.CitizenId ?? "",
|
CitizenId = p.CitizenId ?? "",
|
||||||
FullName = $"{p.Prefix ?? "" }{p.FirstName ?? ""} {p.LastName ?? ""}",
|
FullName = $"{p.Prefix ?? ""}{p.FirstName ?? ""} {p.LastName ?? ""}",
|
||||||
StartTimeMorning = duty.StartTimeMorning,
|
StartTimeMorning = duty.StartTimeMorning,
|
||||||
LeaveTimeAfterNoon = duty.EndTimeAfternoon,
|
LeaveTimeAfterNoon = duty.EndTimeAfternoon,
|
||||||
EffectiveDate = effectiveDate == null ? null : effectiveDate.EffectiveDate.Value.Date
|
EffectiveDate = effectiveDate == null ? null : effectiveDate.EffectiveDate.Value.Date
|
||||||
|
|
@ -1129,7 +1129,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
foreach (var data in rawData)
|
foreach (var data in rawData)
|
||||||
{
|
{
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken);
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
|
|
@ -1148,7 +1148,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
var resObj = new GetAdditionalCheckRequestDto
|
var resObj = new GetAdditionalCheckRequestDto
|
||||||
{
|
{
|
||||||
Id = data.Id,
|
Id = data.Id,
|
||||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||||
CreatedAt = data.CreatedAt,
|
CreatedAt = data.CreatedAt,
|
||||||
CheckDate = data.CheckDate,
|
CheckDate = data.CheckDate,
|
||||||
CheckInEdit = data.CheckInEdit,
|
CheckInEdit = data.CheckInEdit,
|
||||||
|
|
@ -1365,7 +1365,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(d.KeycloakUserId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(d.KeycloakUserId, AccessToken);
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
|
|
@ -1457,7 +1457,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
foreach (var data in rawData)
|
foreach (var data in rawData)
|
||||||
{
|
{
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken);
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
|
|
@ -1661,7 +1661,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
public async Task<ActionResult<ResponseObject>> GetLeaveSummaryByProfileAsync(Guid id, [FromBody] GetLeaveSummaryDto req)
|
public async Task<ActionResult<ResponseObject>> GetLeaveSummaryByProfileAsync(Guid id, [FromBody] GetLeaveSummaryDto req)
|
||||||
{
|
{
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(id);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(id, AccessToken);
|
||||||
|
|
||||||
var thisYear = DateTime.Now.Year;
|
var thisYear = DateTime.Now.Year;
|
||||||
var startDate = req.StartDate;
|
var startDate = req.StartDate;
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||||
|
|
||||||
|
protected string? AccessToken => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||||
|
|
||||||
private Guid OcId
|
private Guid OcId
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -122,7 +124,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
var thisYear = DateTime.Now.Year;
|
var thisYear = DateTime.Now.Year;
|
||||||
|
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||||
|
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
|
|
@ -307,8 +309,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
leaveRequest.LeaveTypeCode = leaveType.Code;
|
leaveRequest.LeaveTypeCode = leaveType.Code;
|
||||||
leaveRequest.Dear = approver;
|
leaveRequest.Dear = approver;
|
||||||
leaveRequest.PositionName = profile.Position == null ? "" : profile.Position.Name;
|
leaveRequest.PositionName = profile.Position == null ? "" : profile.Position;
|
||||||
leaveRequest.PositionLevelName = profile.PositionLevel == null ? "" : profile.PositionLevel.Name;
|
leaveRequest.PositionLevelName = profile.PosLevel == null ? "" : profile.PosLevel.PosLevelName;
|
||||||
leaveRequest.OrganizationName = profile.Oc ?? "";
|
leaveRequest.OrganizationName = profile.Oc ?? "";
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -349,7 +351,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
// return Error("ไม่สามารถขอลาในช่วงเวลาเดียวกันได้");
|
// return Error("ไม่สามารถขอลาในช่วงเวลาเดียวกันได้");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||||
|
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
|
|
@ -533,8 +535,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
leaveRequest.LeaveTypeCode = leaveType.Code;
|
leaveRequest.LeaveTypeCode = leaveType.Code;
|
||||||
leaveRequest.Dear = approver;
|
leaveRequest.Dear = approver;
|
||||||
leaveRequest.PositionName = profile.Position == null ? "" : profile.Position.Name;
|
leaveRequest.PositionName = profile.Position == null ? "" : profile.Position;
|
||||||
leaveRequest.PositionLevelName = profile.PositionLevel == null ? "" : profile.PositionLevel.Name;
|
leaveRequest.PositionLevelName = profile.PosLevel == null ? "" : profile.PosLevel.PosLevelName;
|
||||||
leaveRequest.OrganizationName = profile.Oc ?? "";
|
leaveRequest.OrganizationName = profile.Oc ?? "";
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -594,7 +596,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||||
var thisYear = DateTime.Now.Year;
|
var thisYear = DateTime.Now.Year;
|
||||||
|
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
|
|
@ -627,11 +629,11 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
DateSendLeave = DateTime.Now.Date,
|
DateSendLeave = DateTime.Now.Date,
|
||||||
LeaveTypeName = leaveType.Name,
|
LeaveTypeName = leaveType.Name,
|
||||||
|
|
||||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||||
|
|
||||||
Dear = approver,
|
Dear = approver,
|
||||||
PositionName = profile.Position == null ? "" : profile.Position.Name,
|
PositionName = profile.Position == null ? "" : profile.Position,
|
||||||
PositionLevelName = profile.PositionLevel == null ? "" : profile.PositionLevel.Name,
|
PositionLevelName = profile.PosLevel == null ? "" : profile.PosLevel.PosLevelName,
|
||||||
OrganizationName = profile.Oc ?? "",
|
OrganizationName = profile.Oc ?? "",
|
||||||
|
|
||||||
LeaveLimit = leaveType.Limit,
|
LeaveLimit = leaveType.Limit,
|
||||||
|
|
@ -664,7 +666,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||||
|
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||||
|
|
||||||
var govAge = profile!.DateStart!.Value.Date.DiffDay(DateTime.Now.Date);
|
var govAge = profile!.DateStart!.Value.Date.DiffDay(DateTime.Now.Date);
|
||||||
|
|
||||||
|
|
@ -813,7 +815,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
foreach (var item in data)
|
foreach (var item in data)
|
||||||
{
|
{
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(item.KeycloakUserId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(item.KeycloakUserId, AccessToken);
|
||||||
|
|
||||||
var resData = new GetLeaveRequestCalendarResultDto
|
var resData = new GetLeaveRequestCalendarResultDto
|
||||||
{
|
{
|
||||||
|
|
@ -822,7 +824,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
LeaveTypeId = item.Type.Id,
|
LeaveTypeId = item.Type.Id,
|
||||||
DateSendLeave = item.CreatedAt.Date,
|
DateSendLeave = item.CreatedAt.Date,
|
||||||
Status = item.LeaveStatus,
|
Status = item.LeaveStatus,
|
||||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||||
LeaveStartDate = item.LeaveStartDate,
|
LeaveStartDate = item.LeaveStartDate,
|
||||||
LeaveEndDate = item.LeaveEndDate,
|
LeaveEndDate = item.LeaveEndDate,
|
||||||
KeycloakId = item.KeycloakUserId
|
KeycloakId = item.KeycloakUserId
|
||||||
|
|
@ -851,7 +853,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||||
|
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
|
|
@ -869,7 +871,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
Id = item.Id,
|
Id = item.Id,
|
||||||
LeaveTypeId = item.Type.Id,
|
LeaveTypeId = item.Type.Id,
|
||||||
LeaveTypeName = item.Type.Name,
|
LeaveTypeName = item.Type.Name,
|
||||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||||
DateSendLeave = item.CreatedAt.Date,
|
DateSendLeave = item.CreatedAt.Date,
|
||||||
IsDelete = item.LeaveStatus == "DELETE",
|
IsDelete = item.LeaveStatus == "DELETE",
|
||||||
Status = item.LeaveStatus,
|
Status = item.LeaveStatus,
|
||||||
|
|
@ -910,7 +912,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
||||||
|
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
|
|
@ -937,7 +939,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
LeaveRange = rawData.LeaveRange ?? "",
|
LeaveRange = rawData.LeaveRange ?? "",
|
||||||
LeaveTypeName = rawData.Type.Name,
|
LeaveTypeName = rawData.Type.Name,
|
||||||
LeaveTypeId = rawData.Type.Id,
|
LeaveTypeId = rawData.Type.Id,
|
||||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||||
DateSendLeave = rawData.CreatedAt,
|
DateSendLeave = rawData.CreatedAt,
|
||||||
Status = rawData.LeaveStatus,
|
Status = rawData.LeaveStatus,
|
||||||
LeaveStartDate = rawData.LeaveStartDate,
|
LeaveStartDate = rawData.LeaveStartDate,
|
||||||
|
|
@ -1046,7 +1048,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
foreach (var item in rawData)
|
foreach (var item in rawData)
|
||||||
{
|
{
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(item.KeycloakUserId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(item.KeycloakUserId, AccessToken);
|
||||||
|
|
||||||
// Get Organization
|
// Get Organization
|
||||||
var org = await _userProfileRepository.GetOrganizationById(profile.OcId ?? Guid.Empty);
|
var org = await _userProfileRepository.GetOrganizationById(profile.OcId ?? Guid.Empty);
|
||||||
|
|
@ -1063,14 +1065,14 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
Id = item.Id,
|
Id = item.Id,
|
||||||
LeaveTypeId = item.Type.Id,
|
LeaveTypeId = item.Type.Id,
|
||||||
LeaveTypeName = item.Type.Name,
|
LeaveTypeName = item.Type.Name,
|
||||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||||
DateSendLeave = item.CreatedAt.Date,
|
DateSendLeave = item.CreatedAt.Date,
|
||||||
Status = item.LeaveStatus,
|
Status = item.LeaveStatus,
|
||||||
CitizenId = profile.CitizenId ?? "",
|
CitizenId = profile.CitizenId ?? "",
|
||||||
LeaveStartDate = item.LeaveStartDate,
|
LeaveStartDate = item.LeaveStartDate,
|
||||||
LeaveEndDate = item.LeaveEndDate,
|
LeaveEndDate = item.LeaveEndDate,
|
||||||
Position = profile.Position == null ? "" : profile.Position.Name,
|
Position = profile.Position == null ? "" : profile.Position,
|
||||||
Level = profile.PositionLevel == null ? "" : profile.PositionLevel.Name,
|
Level = profile.PosLevel == null ? "" : profile.PosLevel.PosLevelName,
|
||||||
Agency = agency == null ? "" : agency.Name,
|
Agency = agency == null ? "" : agency.Name,
|
||||||
Org = gov_agency == null ? "" : gov_agency.Name,
|
Org = gov_agency == null ? "" : gov_agency.Name,
|
||||||
LeaveRange = item.LeaveRange ?? "ALL"
|
LeaveRange = item.LeaveRange ?? "ALL"
|
||||||
|
|
@ -1165,13 +1167,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
foreach (var item in rawData)
|
foreach (var item in rawData)
|
||||||
{
|
{
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(item.KeycloakUserId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(item.KeycloakUserId, AccessToken);
|
||||||
var res = new GetLeaveCancelRequestResultDto
|
var res = new GetLeaveCancelRequestResultDto
|
||||||
{
|
{
|
||||||
Id = item.Id,
|
Id = item.Id,
|
||||||
LeaveTypeId = item.Type.Id,
|
LeaveTypeId = item.Type.Id,
|
||||||
LeaveTypeName = item.Type.Name,
|
LeaveTypeName = item.Type.Name,
|
||||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||||
DateSendLeave = item.CreatedAt.Date,
|
DateSendLeave = item.CreatedAt.Date,
|
||||||
Status = item.LeaveCancelStatus
|
Status = item.LeaveCancelStatus
|
||||||
};
|
};
|
||||||
|
|
@ -1210,7 +1212,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
||||||
|
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
|
|
@ -1221,7 +1223,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
Id = rawData.Id,
|
Id = rawData.Id,
|
||||||
LeaveTypeName = rawData.Type.Name,
|
LeaveTypeName = rawData.Type.Name,
|
||||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||||
Status = rawData.LeaveCancelStatus ?? "",
|
Status = rawData.LeaveCancelStatus ?? "",
|
||||||
LeaveStartDate = rawData.LeaveStartDate,
|
LeaveStartDate = rawData.LeaveStartDate,
|
||||||
LeaveEndDate = rawData.LeaveEndDate,
|
LeaveEndDate = rawData.LeaveEndDate,
|
||||||
|
|
@ -1404,7 +1406,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
|
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
||||||
|
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
{
|
{
|
||||||
|
|
@ -1444,7 +1446,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
LeaveTypeName = rawData.Type.Name,
|
LeaveTypeName = rawData.Type.Name,
|
||||||
LeaveTypeId = rawData.Type.Id,
|
LeaveTypeId = rawData.Type.Id,
|
||||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||||
DateSendLeave = rawData.CreatedAt,
|
DateSendLeave = rawData.CreatedAt,
|
||||||
Status = rawData.LeaveStatus,
|
Status = rawData.LeaveStatus,
|
||||||
LeaveStartDate = rawData.LeaveStartDate,
|
LeaveStartDate = rawData.LeaveStartDate,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue