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 string? AccessToken => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Methods "
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ namespace BMA.EHR.Application.Repositories.Leaves
|
|||
|
||||
protected bool? IsPlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
|
||||
protected string? AccessToken => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Methods "
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken ?? "");
|
||||
if (profile == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
|
|
@ -292,7 +292,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken ?? "");
|
||||
if (profile == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
|
|
@ -312,7 +312,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
// insert to profile leave
|
||||
var profileLeave = await _appDbContext.Set<ProfileLeave>()
|
||||
.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)
|
||||
.FirstOrDefaultAsync();
|
||||
if (profileLeave != null)
|
||||
|
|
@ -404,7 +404,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้");
|
||||
}
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId,AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
|
|
@ -430,7 +430,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
Status = "approve",
|
||||
Reason = rawData.LeaveDetail,
|
||||
|
||||
Profile = profile,
|
||||
ProfileId = profile.Id, // change from profile object to id
|
||||
TypeLeave = leaveType
|
||||
};
|
||||
_appDbContext.Set<ProfileLeave>().Add(profileLeave);
|
||||
|
|
@ -464,7 +464,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้");
|
||||
}
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
|
|
@ -516,11 +516,11 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
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()
|
||||
.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.LeaveStatus == "APPROVE")
|
||||
.ToListAsync();
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
await base.AddAsync(entity);
|
||||
|
||||
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 rootOc = _userProfileRepository.GetRootOcId(profile_id);
|
||||
|
|
@ -88,7 +88,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
|
||||
// send inbox and notification
|
||||
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 body = body_str;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using BMA.EHR.Domain.Models.MetaData;
|
|||
using BMA.EHR.Domain.Models.Organizations;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
|
|
@ -61,18 +60,31 @@ namespace BMA.EHR.Application.Repositories
|
|||
return data;
|
||||
}
|
||||
|
||||
public async Task<Profile?> GetProfileByKeycloakIdAsync(Guid keycloakId)
|
||||
public async Task<GetProfileByKeycloakIdDto?> GetProfileByKeycloakIdAsync(Guid keycloakId, string? accessToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
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);
|
||||
var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak/{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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@
|
|||
|
||||
public class Competency
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string id { get; set; } = string.Empty;
|
||||
public string title { 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 string Messsage { get; set; } = string.Empty;
|
||||
public string Message { get; set; } = string.Empty;
|
||||
|
||||
public int Status { get; set; } = -1;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,10 @@ namespace BMA.EHR.Domain.Models.HR
|
|||
[Comment("เหตุผล")]
|
||||
public string? Reason { get; set; }
|
||||
public virtual List<ProfileLeaveHistory> ProfileLeaveHistorys { get; set; } = new List<ProfileLeaveHistory>();
|
||||
public virtual Profile? Profile { get; set; }
|
||||
//public virtual Profile? Profile { get; set; }
|
||||
[Comment("ประเภทการลา")]
|
||||
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)
|
||||
{
|
||||
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)
|
||||
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 profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
|
|
@ -751,7 +751,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(d.KeycloakUserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(d.KeycloakUserId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
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 profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
|
|
@ -973,7 +973,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
ProfileId = p.Id,
|
||||
CitizenId = p.CitizenId ?? "",
|
||||
FullName = $"{p.Prefix ?? "" }{p.FirstName ?? ""} {p.LastName ?? ""}",
|
||||
FullName = $"{p.Prefix ?? ""}{p.FirstName ?? ""} {p.LastName ?? ""}",
|
||||
StartTimeMorning = duty.StartTimeMorning,
|
||||
LeaveTimeAfterNoon = duty.EndTimeAfternoon,
|
||||
EffectiveDate = effectiveDate == null ? null : effectiveDate.EffectiveDate.Value.Date
|
||||
|
|
@ -1129,7 +1129,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
foreach (var data in rawData)
|
||||
{
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
|
|
@ -1148,7 +1148,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var resObj = new GetAdditionalCheckRequestDto
|
||||
{
|
||||
Id = data.Id,
|
||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
||||
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||
CreatedAt = data.CreatedAt,
|
||||
CheckDate = data.CheckDate,
|
||||
CheckInEdit = data.CheckInEdit,
|
||||
|
|
@ -1365,7 +1365,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(d.KeycloakUserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(d.KeycloakUserId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
|
|
@ -1457,7 +1457,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
foreach (var data in rawData)
|
||||
{
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
|
|
@ -1661,7 +1661,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
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 startDate = req.StartDate;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System.Data.Common;
|
||||
using System.Globalization;
|
||||
using System.IO.Pipelines;
|
||||
using System.Security.Claims;
|
||||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.Commands;
|
||||
using BMA.EHR.Application.Repositories.Leaves.LeaveRequests;
|
||||
|
|
@ -40,6 +41,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
private readonly UserDutyTimeRepository _userDutyTimeRepository;
|
||||
private readonly HolidayRepository _holidayRepository;
|
||||
private readonly UserCalendarRepository _userCalendarRepository;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -53,7 +55,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
DutyTimeRepository dutyTimeRepository,
|
||||
UserDutyTimeRepository userDutyTimeRepository,
|
||||
HolidayRepository holidayRepository,
|
||||
UserCalendarRepository userCalendarRepository)
|
||||
UserCalendarRepository userCalendarRepository,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_leaveRequestRepository = leaveRequestRepository;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
|
|
@ -64,6 +67,30 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
_userDutyTimeRepository = userDutyTimeRepository;
|
||||
_holidayRepository = holidayRepository;
|
||||
_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
|
||||
|
|
@ -74,13 +101,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
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)
|
||||
{
|
||||
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 =
|
||||
await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync(data.KeycloakUserId,
|
||||
|
|
@ -108,8 +135,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
leaveTypeName = data.Type.Name,
|
||||
dear = approver,
|
||||
fullname = fullName,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||
organizationName = profile!.Oc ?? "",
|
||||
leaveDetail = data.LeaveDetail,
|
||||
leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate(),
|
||||
|
|
@ -129,13 +156,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
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)
|
||||
{
|
||||
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 approver = string.Empty;
|
||||
|
|
@ -157,8 +184,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
leaveTypeName = data.Type.Name,
|
||||
dear = approver,
|
||||
fullname = fullName,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||
organizationName = profile!.Oc ?? "",
|
||||
wifeDayName = data.WifeDayName ?? "",
|
||||
wifeDayDateBorn = data.WifeDayDateBorn ?? "",
|
||||
|
|
@ -173,13 +200,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
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)
|
||||
{
|
||||
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 approver = string.Empty;
|
||||
|
|
@ -203,8 +230,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
leaveTypeName = data.Type.Name,
|
||||
dear = approver,
|
||||
fullname = fullName,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||
organizationName = profile!.Oc ?? "",
|
||||
|
||||
restDayOldTotal = data.RestDayOldTotal,
|
||||
|
|
@ -224,13 +251,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
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)
|
||||
{
|
||||
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 approver = string.Empty;
|
||||
|
|
@ -254,8 +281,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
leaveTypeName = data.Type.Name,
|
||||
dear = approver,
|
||||
fullname = fullName,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||
organizationName = profile!.Oc ?? "",
|
||||
|
||||
|
||||
|
|
@ -282,8 +309,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
leaveTypeName = data.Type.Name,
|
||||
dear = approver,
|
||||
fullname = fullName,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||
organizationName = profile!.Oc ?? "",
|
||||
|
||||
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)
|
||||
{
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
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 approver = string.Empty;
|
||||
|
|
@ -335,8 +362,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
leaveTypeName = data.Type.Name,
|
||||
dear = approver,
|
||||
fullname = fullName,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||
organizationName = profile!.Oc ?? "",
|
||||
|
||||
absentDaySummon = data.AbsentDaySummon,
|
||||
|
|
@ -355,13 +382,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
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)
|
||||
{
|
||||
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 approver = string.Empty;
|
||||
|
|
@ -383,8 +410,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
leaveTypeName = data.Type.Name,
|
||||
dear = approver,
|
||||
fullname = fullName,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||
organizationName = profile!.Oc ?? "",
|
||||
|
||||
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)
|
||||
{
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
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 approver = string.Empty;
|
||||
|
|
@ -439,8 +466,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
dear = approver,
|
||||
fullname = fullName,
|
||||
fullnameEng = "",
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||
organizationName = profile!.Oc ?? "",
|
||||
|
||||
leaveDateStart = data.LeaveStartDate.Date.ToThaiShortDate(),
|
||||
|
|
@ -452,13 +479,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
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)
|
||||
{
|
||||
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 approver = string.Empty;
|
||||
|
|
@ -480,8 +507,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
leaveTypeName = data.Type.Name,
|
||||
dear = approver,
|
||||
fullname = fullName,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||
organizationName = profile!.Oc ?? "",
|
||||
|
||||
leaveSalary = data.LeaveSalary,
|
||||
|
|
@ -507,13 +534,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
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)
|
||||
{
|
||||
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 approver = string.Empty;
|
||||
|
|
@ -535,8 +562,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
leaveTypeName = data.Type.Name,
|
||||
dear = approver,
|
||||
fullname = fullName,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||
organizationName = profile!.Oc ?? "",
|
||||
|
||||
|
||||
|
|
@ -657,13 +684,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(data.KeycloakUserId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
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 approver = string.Empty;
|
||||
|
|
@ -684,8 +711,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
dateSendLeave = data.CreatedAt.Date.ToThaiShortDate(),
|
||||
leaveTypeName = data.Type.Name,
|
||||
fullname = fullName,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position!.Name,
|
||||
positionName = profile!.Position == null ? "-" : profile!.Position,
|
||||
positionLeaveName = profile!.Position == null ? "-" : profile!.Position,
|
||||
organizationName = profile!.Oc ?? "",
|
||||
leaveDateStart = data.LeaveStartDate.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");
|
||||
|
||||
protected string? AccessToken => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||
|
||||
private Guid OcId
|
||||
{
|
||||
get
|
||||
|
|
@ -122,7 +124,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var thisYear = DateTime.Now.Year;
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
|
|
@ -307,8 +309,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
leaveRequest.LeaveTypeCode = leaveType.Code;
|
||||
leaveRequest.Dear = approver;
|
||||
leaveRequest.PositionName = profile.Position == null ? "" : profile.Position.Name;
|
||||
leaveRequest.PositionLevelName = profile.PositionLevel == null ? "" : profile.PositionLevel.Name;
|
||||
leaveRequest.PositionName = profile.Position == null ? "" : profile.Position;
|
||||
leaveRequest.PositionLevelName = profile.PosLevel == null ? "" : profile.PosLevel.PosLevelName;
|
||||
leaveRequest.OrganizationName = profile.Oc ?? "";
|
||||
|
||||
|
||||
|
|
@ -349,7 +351,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
// return Error("ไม่สามารถขอลาในช่วงเวลาเดียวกันได้");
|
||||
// }
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
|
|
@ -533,8 +535,8 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
leaveRequest.LeaveTypeCode = leaveType.Code;
|
||||
leaveRequest.Dear = approver;
|
||||
leaveRequest.PositionName = profile.Position == null ? "" : profile.Position.Name;
|
||||
leaveRequest.PositionLevelName = profile.PositionLevel == null ? "" : profile.PositionLevel.Name;
|
||||
leaveRequest.PositionName = profile.Position == null ? "" : profile.Position;
|
||||
leaveRequest.PositionLevelName = profile.PosLevel == null ? "" : profile.PosLevel.PosLevelName;
|
||||
leaveRequest.OrganizationName = profile.Oc ?? "";
|
||||
|
||||
|
||||
|
|
@ -594,7 +596,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
var thisYear = DateTime.Now.Year;
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
|
|
@ -627,11 +629,11 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
DateSendLeave = DateTime.Now.Date,
|
||||
LeaveTypeName = leaveType.Name,
|
||||
|
||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
||||
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||
|
||||
Dear = approver,
|
||||
PositionName = profile.Position == null ? "" : profile.Position.Name,
|
||||
PositionLevelName = profile.PositionLevel == null ? "" : profile.PositionLevel.Name,
|
||||
PositionName = profile.Position == null ? "" : profile.Position,
|
||||
PositionLevelName = profile.PosLevel == null ? "" : profile.PosLevel.PosLevelName,
|
||||
OrganizationName = profile.Oc ?? "",
|
||||
|
||||
LeaveLimit = leaveType.Limit,
|
||||
|
|
@ -664,7 +666,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
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);
|
||||
|
||||
|
|
@ -813,7 +815,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
foreach (var item in data)
|
||||
{
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(item.KeycloakUserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(item.KeycloakUserId, AccessToken);
|
||||
|
||||
var resData = new GetLeaveRequestCalendarResultDto
|
||||
{
|
||||
|
|
@ -822,7 +824,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
LeaveTypeId = item.Type.Id,
|
||||
DateSendLeave = item.CreatedAt.Date,
|
||||
Status = item.LeaveStatus,
|
||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
||||
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||
LeaveStartDate = item.LeaveStartDate,
|
||||
LeaveEndDate = item.LeaveEndDate,
|
||||
KeycloakId = item.KeycloakUserId
|
||||
|
|
@ -851,7 +853,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
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)
|
||||
{
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
|
|
@ -869,7 +871,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
Id = item.Id,
|
||||
LeaveTypeId = item.Type.Id,
|
||||
LeaveTypeName = item.Type.Name,
|
||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
||||
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||
DateSendLeave = item.CreatedAt.Date,
|
||||
IsDelete = item.LeaveStatus == "DELETE",
|
||||
Status = item.LeaveStatus,
|
||||
|
|
@ -910,7 +912,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
|
|
@ -937,7 +939,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
LeaveRange = rawData.LeaveRange ?? "",
|
||||
LeaveTypeName = rawData.Type.Name,
|
||||
LeaveTypeId = rawData.Type.Id,
|
||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
||||
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||
DateSendLeave = rawData.CreatedAt,
|
||||
Status = rawData.LeaveStatus,
|
||||
LeaveStartDate = rawData.LeaveStartDate,
|
||||
|
|
@ -1046,7 +1048,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
foreach (var item in rawData)
|
||||
{
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(item.KeycloakUserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(item.KeycloakUserId, AccessToken);
|
||||
|
||||
// Get Organization
|
||||
var org = await _userProfileRepository.GetOrganizationById(profile.OcId ?? Guid.Empty);
|
||||
|
|
@ -1063,14 +1065,14 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
Id = item.Id,
|
||||
LeaveTypeId = item.Type.Id,
|
||||
LeaveTypeName = item.Type.Name,
|
||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
||||
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||
DateSendLeave = item.CreatedAt.Date,
|
||||
Status = item.LeaveStatus,
|
||||
CitizenId = profile.CitizenId ?? "",
|
||||
LeaveStartDate = item.LeaveStartDate,
|
||||
LeaveEndDate = item.LeaveEndDate,
|
||||
Position = profile.Position == null ? "" : profile.Position.Name,
|
||||
Level = profile.PositionLevel == null ? "" : profile.PositionLevel.Name,
|
||||
Position = profile.Position == null ? "" : profile.Position,
|
||||
Level = profile.PosLevel == null ? "" : profile.PosLevel.PosLevelName,
|
||||
Agency = agency == null ? "" : agency.Name,
|
||||
Org = gov_agency == null ? "" : gov_agency.Name,
|
||||
LeaveRange = item.LeaveRange ?? "ALL"
|
||||
|
|
@ -1165,13 +1167,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
foreach (var item in rawData)
|
||||
{
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(item.KeycloakUserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(item.KeycloakUserId, AccessToken);
|
||||
var res = new GetLeaveCancelRequestResultDto
|
||||
{
|
||||
Id = item.Id,
|
||||
LeaveTypeId = item.Type.Id,
|
||||
LeaveTypeName = item.Type.Name,
|
||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
||||
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||
DateSendLeave = item.CreatedAt.Date,
|
||||
Status = item.LeaveCancelStatus
|
||||
};
|
||||
|
|
@ -1210,7 +1212,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
|
|
@ -1221,7 +1223,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
Id = rawData.Id,
|
||||
LeaveTypeName = rawData.Type.Name,
|
||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
||||
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||
Status = rawData.LeaveCancelStatus ?? "",
|
||||
LeaveStartDate = rawData.LeaveStartDate,
|
||||
LeaveEndDate = rawData.LeaveEndDate,
|
||||
|
|
@ -1404,7 +1406,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
||||
|
||||
if (profile == null)
|
||||
{
|
||||
|
|
@ -1444,7 +1446,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
LeaveTypeName = rawData.Type.Name,
|
||||
LeaveTypeId = rawData.Type.Id,
|
||||
FullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}",
|
||||
FullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
|
||||
DateSendLeave = rawData.CreatedAt,
|
||||
Status = rawData.LeaveStatus,
|
||||
LeaveStartDate = rawData.LeaveStartDate,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue