fix: Change Profile Link to Guid
This commit is contained in:
parent
ee2a0f1e36
commit
b7120551b5
6 changed files with 1213 additions and 47 deletions
|
|
@ -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)
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue