Merge branch 'develop' of github.com:Frappet/BMA-EHR-BackEnd into develop
This commit is contained in:
commit
ee2aa136b9
15 changed files with 1356 additions and 102 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);
|
||||||
|
|
@ -312,7 +312,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
// insert to profile leave
|
// insert to profile leave
|
||||||
var profileLeave = await _appDbContext.Set<ProfileLeave>()
|
var profileLeave = await _appDbContext.Set<ProfileLeave>()
|
||||||
.Where(x => x.TypeLeave.Id == leaveType.Id)
|
.Where(x => x.TypeLeave.Id == leaveType.Id)
|
||||||
.Where(x => x.Profile.Id == profile.Id)
|
.Where(x => x.ProfileId == profile.Id)
|
||||||
.Where(x => x.DateStartLeave == rawData.LeaveStartDate && x.DateEndLeave == rawData.LeaveEndDate)
|
.Where(x => x.DateStartLeave == rawData.LeaveStartDate && x.DateEndLeave == rawData.LeaveEndDate)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
if (profileLeave != null)
|
if (profileLeave != null)
|
||||||
|
|
@ -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);
|
||||||
|
|
@ -430,7 +430,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
Status = "approve",
|
Status = "approve",
|
||||||
Reason = rawData.LeaveDetail,
|
Reason = rawData.LeaveDetail,
|
||||||
|
|
||||||
Profile = profile,
|
ProfileId = profile.Id, // change from profile object to id
|
||||||
TypeLeave = leaveType
|
TypeLeave = leaveType
|
||||||
};
|
};
|
||||||
_appDbContext.Set<ProfileLeave>().Add(profileLeave);
|
_appDbContext.Set<ProfileLeave>().Add(profileLeave);
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ using BMA.EHR.Domain.Models.MetaData;
|
||||||
using BMA.EHR.Domain.Models.Organizations;
|
using BMA.EHR.Domain.Models.Organizations;
|
||||||
using BMA.EHR.Domain.Shared;
|
using BMA.EHR.Domain.Shared;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
@ -61,18 +60,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
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@
|
||||||
|
|
||||||
public class Competency
|
public class Competency
|
||||||
{
|
{
|
||||||
public int id { get; set; }
|
public string id { get; set; } = string.Empty;
|
||||||
public string title { get; set; } = string.Empty;
|
public string title { get; set; } = string.Empty;
|
||||||
public string description { get; set; } = string.Empty;
|
public string description { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,10 @@ namespace BMA.EHR.Domain.Models.HR
|
||||||
[Comment("เหตุผล")]
|
[Comment("เหตุผล")]
|
||||||
public string? Reason { get; set; }
|
public string? Reason { get; set; }
|
||||||
public virtual List<ProfileLeaveHistory> ProfileLeaveHistorys { get; set; } = new List<ProfileLeaveHistory>();
|
public virtual List<ProfileLeaveHistory> ProfileLeaveHistorys { get; set; } = new List<ProfileLeaveHistory>();
|
||||||
public virtual Profile? Profile { get; set; }
|
//public virtual Profile? Profile { get; set; }
|
||||||
[Comment("ประเภทการลา")]
|
[Comment("ประเภทการลา")]
|
||||||
public virtual TypeLeave? TypeLeave { get; set; }
|
public virtual TypeLeave? TypeLeave { get; set; }
|
||||||
|
|
||||||
|
public Guid ProfileId { get; set; } = Guid.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1116
BMA.EHR.Infrastructure/Migrations/LeaveDb/20240604030402_Change Profile Link to GUID.Designer.cs
generated
Normal file
1116
BMA.EHR.Infrastructure/Migrations/LeaveDb/20240604030402_Change Profile Link to GUID.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,22 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class ChangeProfileLinktoGUID : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO.Pipelines;
|
using System.IO.Pipelines;
|
||||||
|
using System.Security.Claims;
|
||||||
using BMA.EHR.Application.Repositories;
|
using BMA.EHR.Application.Repositories;
|
||||||
using BMA.EHR.Application.Repositories.Commands;
|
using BMA.EHR.Application.Repositories.Commands;
|
||||||
using BMA.EHR.Application.Repositories.Leaves.LeaveRequests;
|
using BMA.EHR.Application.Repositories.Leaves.LeaveRequests;
|
||||||
|
|
@ -40,6 +41,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
private readonly UserDutyTimeRepository _userDutyTimeRepository;
|
private readonly UserDutyTimeRepository _userDutyTimeRepository;
|
||||||
private readonly HolidayRepository _holidayRepository;
|
private readonly HolidayRepository _holidayRepository;
|
||||||
private readonly UserCalendarRepository _userCalendarRepository;
|
private readonly UserCalendarRepository _userCalendarRepository;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -53,7 +55,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
DutyTimeRepository dutyTimeRepository,
|
DutyTimeRepository dutyTimeRepository,
|
||||||
UserDutyTimeRepository userDutyTimeRepository,
|
UserDutyTimeRepository userDutyTimeRepository,
|
||||||
HolidayRepository holidayRepository,
|
HolidayRepository holidayRepository,
|
||||||
UserCalendarRepository userCalendarRepository)
|
UserCalendarRepository userCalendarRepository,
|
||||||
|
IHttpContextAccessor httpContextAccessor)
|
||||||
{
|
{
|
||||||
_leaveRequestRepository = leaveRequestRepository;
|
_leaveRequestRepository = leaveRequestRepository;
|
||||||
_userProfileRepository = userProfileRepository;
|
_userProfileRepository = userProfileRepository;
|
||||||
|
|
@ -64,6 +67,30 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
_userDutyTimeRepository = userDutyTimeRepository;
|
_userDutyTimeRepository = userDutyTimeRepository;
|
||||||
_holidayRepository = holidayRepository;
|
_holidayRepository = holidayRepository;
|
||||||
_userCalendarRepository = userCalendarRepository;
|
_userCalendarRepository = userCalendarRepository;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region " Properties "
|
||||||
|
|
||||||
|
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
|
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||||
|
|
||||||
|
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||||
|
|
||||||
|
private string? AccessToken => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||||
|
|
||||||
|
private Guid OcId
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (UserId != null || UserId != "")
|
||||||
|
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
||||||
|
else
|
||||||
|
return Guid.Empty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -74,13 +101,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
private async Task<dynamic> GetReport01(LeaveRequest data)
|
private async Task<dynamic> GetReport01(LeaveRequest data)
|
||||||
{
|
{
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
var fullName = $"{profile!.Prefix!.Name}{profile!.FirstName} {profile!.LastName}";
|
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||||
|
|
||||||
var lastLeaveRequest =
|
var lastLeaveRequest =
|
||||||
await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync(data.KeycloakUserId,
|
await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync(data.KeycloakUserId,
|
||||||
|
|
@ -108,8 +135,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
leaveTypeName = data.Type.Name,
|
leaveTypeName = data.Type.Name,
|
||||||
dear = approver,
|
dear = approver,
|
||||||
fullname = fullName,
|
fullname = fullName,
|
||||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
organizationName = profile!.Oc ?? "",
|
organizationName = profile!.Oc ?? "",
|
||||||
leaveDetail = data.LeaveDetail,
|
leaveDetail = data.LeaveDetail,
|
||||||
leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate(),
|
leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate(),
|
||||||
|
|
@ -129,13 +156,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
private async Task<dynamic> GetReport02(LeaveRequest data)
|
private async Task<dynamic> GetReport02(LeaveRequest data)
|
||||||
{
|
{
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
var fullName = $"{profile!.Prefix!.Name}{profile!.FirstName} {profile!.LastName}";
|
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||||
|
|
||||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||||
var approver = string.Empty;
|
var approver = string.Empty;
|
||||||
|
|
@ -157,8 +184,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
leaveTypeName = data.Type.Name,
|
leaveTypeName = data.Type.Name,
|
||||||
dear = approver,
|
dear = approver,
|
||||||
fullname = fullName,
|
fullname = fullName,
|
||||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
organizationName = profile!.Oc ?? "",
|
organizationName = profile!.Oc ?? "",
|
||||||
wifeDayName = data.WifeDayName ?? "",
|
wifeDayName = data.WifeDayName ?? "",
|
||||||
wifeDayDateBorn = data.WifeDayDateBorn ?? "",
|
wifeDayDateBorn = data.WifeDayDateBorn ?? "",
|
||||||
|
|
@ -173,13 +200,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
private async Task<dynamic> GetReport03(LeaveRequest data)
|
private async Task<dynamic> GetReport03(LeaveRequest data)
|
||||||
{
|
{
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
var fullName = $"{profile!.Prefix!.Name}{profile!.FirstName} {profile!.LastName}";
|
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||||
|
|
||||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||||
var approver = string.Empty;
|
var approver = string.Empty;
|
||||||
|
|
@ -203,8 +230,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
leaveTypeName = data.Type.Name,
|
leaveTypeName = data.Type.Name,
|
||||||
dear = approver,
|
dear = approver,
|
||||||
fullname = fullName,
|
fullname = fullName,
|
||||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
organizationName = profile!.Oc ?? "",
|
organizationName = profile!.Oc ?? "",
|
||||||
|
|
||||||
restDayOldTotal = data.RestDayOldTotal,
|
restDayOldTotal = data.RestDayOldTotal,
|
||||||
|
|
@ -224,13 +251,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
private async Task<dynamic> GetReport04(LeaveRequest data, bool isHajj = false)
|
private async Task<dynamic> GetReport04(LeaveRequest data, bool isHajj = false)
|
||||||
{
|
{
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
var fullName = $"{profile!.Prefix!.Name}{profile!.FirstName} {profile!.LastName}";
|
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||||
|
|
||||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||||
var approver = string.Empty;
|
var approver = string.Empty;
|
||||||
|
|
@ -254,8 +281,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
leaveTypeName = data.Type.Name,
|
leaveTypeName = data.Type.Name,
|
||||||
dear = approver,
|
dear = approver,
|
||||||
fullname = fullName,
|
fullname = fullName,
|
||||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
organizationName = profile!.Oc ?? "",
|
organizationName = profile!.Oc ?? "",
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -282,8 +309,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
leaveTypeName = data.Type.Name,
|
leaveTypeName = data.Type.Name,
|
||||||
dear = approver,
|
dear = approver,
|
||||||
fullname = fullName,
|
fullname = fullName,
|
||||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
organizationName = profile!.Oc ?? "",
|
organizationName = profile!.Oc ?? "",
|
||||||
|
|
||||||
leavebirthDate = data.LeaveBirthDate == null ? "" : data.LeaveBirthDate.Value.Date.ToThaiShortDate(),
|
leavebirthDate = data.LeaveBirthDate == null ? "" : data.LeaveBirthDate.Value.Date.ToThaiShortDate(),
|
||||||
|
|
@ -307,13 +334,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
private async Task<dynamic> GetReport05(LeaveRequest data)
|
private async Task<dynamic> GetReport05(LeaveRequest data)
|
||||||
{
|
{
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
var fullName = $"{profile!.Prefix!.Name}{profile!.FirstName} {profile!.LastName}";
|
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||||
|
|
||||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||||
var approver = string.Empty;
|
var approver = string.Empty;
|
||||||
|
|
@ -335,8 +362,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
leaveTypeName = data.Type.Name,
|
leaveTypeName = data.Type.Name,
|
||||||
dear = approver,
|
dear = approver,
|
||||||
fullname = fullName,
|
fullname = fullName,
|
||||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
organizationName = profile!.Oc ?? "",
|
organizationName = profile!.Oc ?? "",
|
||||||
|
|
||||||
absentDaySummon = data.AbsentDaySummon,
|
absentDaySummon = data.AbsentDaySummon,
|
||||||
|
|
@ -355,13 +382,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
private async Task<dynamic> GetReport06(LeaveRequest data)
|
private async Task<dynamic> GetReport06(LeaveRequest data)
|
||||||
{
|
{
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
var fullName = $"{profile!.Prefix!.Name}{profile!.FirstName} {profile!.LastName}";
|
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||||
|
|
||||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||||
var approver = string.Empty;
|
var approver = string.Empty;
|
||||||
|
|
@ -383,8 +410,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
leaveTypeName = data.Type.Name,
|
leaveTypeName = data.Type.Name,
|
||||||
dear = approver,
|
dear = approver,
|
||||||
fullname = fullName,
|
fullname = fullName,
|
||||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
organizationName = profile!.Oc ?? "",
|
organizationName = profile!.Oc ?? "",
|
||||||
|
|
||||||
leavebirthDate = data.LeaveBirthDate == null ? "" : data.LeaveBirthDate.Value.Date.ToThaiShortDate(),
|
leavebirthDate = data.LeaveBirthDate == null ? "" : data.LeaveBirthDate.Value.Date.ToThaiShortDate(),
|
||||||
|
|
@ -410,13 +437,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
private async Task<dynamic> GetReport07(LeaveRequest data)
|
private async Task<dynamic> GetReport07(LeaveRequest data)
|
||||||
{
|
{
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
var fullName = $"{profile!.Prefix!.Name}{profile!.FirstName} {profile!.LastName}";
|
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||||
|
|
||||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||||
var approver = string.Empty;
|
var approver = string.Empty;
|
||||||
|
|
@ -439,8 +466,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
dear = approver,
|
dear = approver,
|
||||||
fullname = fullName,
|
fullname = fullName,
|
||||||
fullnameEng = "",
|
fullnameEng = "",
|
||||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
organizationName = profile!.Oc ?? "",
|
organizationName = profile!.Oc ?? "",
|
||||||
|
|
||||||
leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate(),
|
leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate(),
|
||||||
|
|
@ -452,13 +479,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
private async Task<dynamic> GetReport08(LeaveRequest data)
|
private async Task<dynamic> GetReport08(LeaveRequest data)
|
||||||
{
|
{
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
var fullName = $"{profile!.Prefix!.Name}{profile!.FirstName} {profile!.LastName}";
|
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||||
|
|
||||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||||
var approver = string.Empty;
|
var approver = string.Empty;
|
||||||
|
|
@ -480,8 +507,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
leaveTypeName = data.Type.Name,
|
leaveTypeName = data.Type.Name,
|
||||||
dear = approver,
|
dear = approver,
|
||||||
fullname = fullName,
|
fullname = fullName,
|
||||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
organizationName = profile!.Oc ?? "",
|
organizationName = profile!.Oc ?? "",
|
||||||
|
|
||||||
leaveSalary = data.LeaveSalary,
|
leaveSalary = data.LeaveSalary,
|
||||||
|
|
@ -507,13 +534,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
private async Task<dynamic> GetReport09(LeaveRequest data)
|
private async Task<dynamic> GetReport09(LeaveRequest data)
|
||||||
{
|
{
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
var fullName = $"{profile!.Prefix!.Name}{profile!.FirstName} {profile!.LastName}";
|
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||||
|
|
||||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||||
var approver = string.Empty;
|
var approver = string.Empty;
|
||||||
|
|
@ -535,8 +562,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
leaveTypeName = data.Type.Name,
|
leaveTypeName = data.Type.Name,
|
||||||
dear = approver,
|
dear = approver,
|
||||||
fullname = fullName,
|
fullname = fullName,
|
||||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
organizationName = profile!.Oc ?? "",
|
organizationName = profile!.Oc ?? "",
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -657,13 +684,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
var fullName = $"{profile!.Prefix!.Name}{profile!.FirstName} {profile!.LastName}";
|
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||||
|
|
||||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||||
var approver = string.Empty;
|
var approver = string.Empty;
|
||||||
|
|
@ -684,8 +711,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(),
|
dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(),
|
||||||
leaveTypeName = data.Type.Name,
|
leaveTypeName = data.Type.Name,
|
||||||
fullname = fullName,
|
fullname = fullName,
|
||||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||||
organizationName = profile!.Oc ?? "",
|
organizationName = profile!.Oc ?? "",
|
||||||
leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate(),
|
leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate(),
|
||||||
leaveDateEnd = data.LeaveEndDate.Date.ToThaiShortDate(),
|
leaveDateEnd = data.LeaveEndDate.Date.ToThaiShortDate(),
|
||||||
|
|
|
||||||
|
|
@ -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