Merge branch 'develop' of github.com:Frappet/BMA-EHR-BackEnd into develop
This commit is contained in:
commit
89b4c71dbd
23 changed files with 814 additions and 218 deletions
|
|
@ -52,7 +52,7 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
get
|
||||
{
|
||||
if (UserId != null || UserId != "")
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), AccessToken);
|
||||
else
|
||||
return Guid.Empty;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
get
|
||||
{
|
||||
if (UserId != null || UserId != "")
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), AccessToken);
|
||||
else
|
||||
return Guid.Empty;
|
||||
}
|
||||
|
|
@ -12274,13 +12274,37 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
{
|
||||
try
|
||||
{
|
||||
var profiles = await _dbContext.Set<Profile>().ToListAsync();
|
||||
var profiles = await _dbContext.Set<Profile>()
|
||||
.Include(x => x.Prefix)
|
||||
.Include(x => x.Gender)
|
||||
.Include(x => x.PositionLevel)
|
||||
.Include(x => x.PositionType)
|
||||
.Include(x => x.ChangeNames)
|
||||
.Include(x => x.FatherHistory)
|
||||
.Include(x => x.MotherHistory)
|
||||
.Include(x => x.CoupleHistory)
|
||||
.Include(x => x.Childrens)
|
||||
.Include(x => x.Educations)
|
||||
.Include(x => x.Abilitys)
|
||||
.Include(x => x.Disciplines)
|
||||
.Include(x => x.Leaves)
|
||||
.Include(x => x.Dutys)
|
||||
.Include(x => x.Salaries)
|
||||
.Include(x => x.Nopaids)
|
||||
.Include(x => x.Certificates)
|
||||
.Include(x => x.Trainings)
|
||||
.Include(x => x.Insignias)
|
||||
.Include(x => x.Honors)
|
||||
.Include(x => x.Assessments)
|
||||
.Include(x => x.Others)
|
||||
.ToListAsync();
|
||||
|
||||
//var _baseAPI = _configuration["API"];
|
||||
var _baseAPI = "http://localhost:13001/api/v1";
|
||||
// create new profile
|
||||
foreach (var recv in profiles)
|
||||
foreach (var profile in profiles)
|
||||
{
|
||||
/*ข้อมูล Profile ใหม่*/
|
||||
var apiUrl = $"{_configuration["API"]}/org/profile/all";
|
||||
var apiUrl = $"{_baseAPI}/org/profile/all";
|
||||
var profileId = string.Empty;
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
|
|
@ -12289,129 +12313,520 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
var _res = await client.PostAsJsonAsync(apiUrl, new
|
||||
{
|
||||
rank = string.Empty,
|
||||
prefix = placementProfile.Prefix == null ? string.Empty : placementProfile.Prefix,
|
||||
firstName = placementProfile.Firstname == null ? string.Empty : placementProfile.Firstname,
|
||||
lastName = placementProfile.Lastname == null ? string.Empty : placementProfile.Lastname,
|
||||
citizenId = placementProfile.CitizenId == null ? string.Empty : placementProfile.CitizenId,
|
||||
position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName,
|
||||
posLevelId = placementProfile.posLevelId == null ? string.Empty : placementProfile.posLevelId,
|
||||
posTypeId = placementProfile.posTypeId == null ? string.Empty : placementProfile.posTypeId,
|
||||
email = placementProfile.Email == null ? string.Empty : placementProfile.Email,
|
||||
phone = placementProfile.MobilePhone == null ? string.Empty : placementProfile.MobilePhone,
|
||||
keycloak = string.Empty,
|
||||
isProbation = false,
|
||||
isLeave = false,
|
||||
dateRetire = (DateTime?)null,
|
||||
dateAppoint = placementProfile.RecruitDate == null ? (DateTime?)null : placementProfile.RecruitDate,
|
||||
dateStart = (DateTime?)null,
|
||||
govAgeAbsent = 0,
|
||||
govAgePlus = 0,
|
||||
birthDate = placementProfile.DateOfBirth == null ? (DateTime?)null : placementProfile.DateOfBirth,
|
||||
reasonSameDate = (DateTime?)null,
|
||||
ethnicity = placementProfile.Race == null ? string.Empty : placementProfile.Race,
|
||||
telephoneNumber = placementProfile.Telephone == null ? string.Empty : placementProfile.Telephone,
|
||||
nationality = placementProfile.Nationality == null ? string.Empty : placementProfile.Nationality,
|
||||
gender = placementProfile.Gender == null ? string.Empty : placementProfile.Gender,
|
||||
relationship = placementProfile.Relationship == null ? string.Empty : placementProfile.Relationship,
|
||||
religion = placementProfile.Religion == null ? string.Empty : placementProfile.Religion,
|
||||
bloodGroup = string.Empty,
|
||||
registrationAddress = placementProfile.RegistAddress == null ? string.Empty : placementProfile.RegistAddress,
|
||||
registrationProvinceId = (String?)null,
|
||||
registrationDistrictId = (String?)null,
|
||||
registrationSubDistrictId = (String?)null,
|
||||
registrationZipCode = placementProfile.RegistZipCode == null ? string.Empty : placementProfile.RegistZipCode,
|
||||
currentAddress = placementProfile.CurrentAddress == null ? string.Empty : placementProfile.CurrentAddress,
|
||||
currentProvinceId = (String?)null,
|
||||
currentDistrictId = (String?)null,
|
||||
currentSubDistrictId = (String?)null,
|
||||
currentZipCode = placementProfile.CurrentZipCode == null ? string.Empty : placementProfile.CurrentZipCode,
|
||||
prefix = profile.Prefix != null ? profile.Prefix.Name.ToString() : string.Empty,
|
||||
firstName = profile.FirstName,
|
||||
lastName = profile.LastName,
|
||||
citizenId = profile.CitizenId,
|
||||
position = profile.Position,
|
||||
posLevelId = profile.PositionLevel != null ? profile.PositionLevel.Name.ToString() : string.Empty,
|
||||
posTypeId = profile.PositionType != null ? profile.PositionType.Name.ToString() : string.Empty,
|
||||
email = string.Empty,
|
||||
phone = string.Empty,
|
||||
keycloak = profile.KeycloakId,
|
||||
isProbation = profile.IsProbation,
|
||||
isLeave = profile.IsLeave,
|
||||
dateRetire = profile.DateRetire,
|
||||
dateAppoint = profile.DateAppoint,
|
||||
dateStart = profile.DateStart,
|
||||
govAgeAbsent = profile.GovAgeAbsent,
|
||||
govAgePlus = profile.GovAgePlus,
|
||||
birthDate = profile.BirthDate,
|
||||
reasonSameDate = profile.ReasonSameDate,
|
||||
ethnicity = profile.Race,
|
||||
telephoneNumber = profile.TelephoneNumber,
|
||||
nationality = profile.Nationality == null ? string.Empty : profile.Nationality,
|
||||
gender = profile.Gender != null ? profile.Gender.Name.ToString() : null,
|
||||
relationship = profile.RelationshipId != null
|
||||
? await _dbContext.Set<Relationship>().Where(r => r.Id == profile.RelationshipId).Select(r => r.Name).FirstOrDefaultAsync()
|
||||
: null,
|
||||
religion = profile.ReligionId != null
|
||||
? await _dbContext.Set<Religion>().Where(r => r.Id == profile.ReligionId).Select(r => r.Name).FirstOrDefaultAsync()
|
||||
: null,
|
||||
bloodGroup = profile.BloodGroupId != null
|
||||
? await _dbContext.Set<BloodGroup>().Where(r => r.Id == profile.BloodGroupId).Select(r => r.Name).FirstOrDefaultAsync()
|
||||
: null,
|
||||
registrationAddress = profile.RegistrationAddress,
|
||||
registrationProvinceId = profile.RegistrationProvinceId != null
|
||||
? await _dbContext.Set<Province>().Where(r => r.Id == profile.RegistrationProvinceId).Select(r => r.Name).FirstOrDefaultAsync()
|
||||
: null,
|
||||
registrationDistrictId = profile.RegistrationDistrictId != null
|
||||
? await _dbContext.Set<District>().Where(r => r.Id == profile.RegistrationDistrictId).Select(r => r.Name).FirstOrDefaultAsync()
|
||||
: null,
|
||||
registrationSubDistrictId = profile.RegistrationSubDistrictId != null
|
||||
? await _dbContext.Set<SubDistrict>().Where(r => r.Id == profile.RegistrationSubDistrictId).Select(r => r.Name).FirstOrDefaultAsync()
|
||||
: null,
|
||||
registrationZipCode = profile.RegistrationZipCode,
|
||||
currentAddress = profile.CurrentAddress,
|
||||
currentProvinceId = profile.CurrentProvinceId != null
|
||||
? await _dbContext.Set<Province>().Where(r => r.Id == profile.CurrentProvinceId).Select(r => r.Name).FirstOrDefaultAsync()
|
||||
: null,
|
||||
currentDistrictId = profile.CurrentDistrictId != null
|
||||
? await _dbContext.Set<District>().Where(r => r.Id == profile.CurrentDistrictId).Select(r => r.Name).FirstOrDefaultAsync()
|
||||
: null,
|
||||
currentSubDistrictId = profile.CurrentSubDistrictId != null
|
||||
? await _dbContext.Set<SubDistrict>().Where(r => r.Id == profile.CurrentSubDistrictId).Select(r => r.Name).FirstOrDefaultAsync()
|
||||
: null,
|
||||
currentZipCode = profile.CurrentZipCode,
|
||||
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
profileId = JsonConvert.DeserializeObject<PlacementProfileId>(_result).result;
|
||||
//ยังไม่ SAVE จริง
|
||||
//profileId = JsonConvert.DeserializeObject<PlacementProfileId>(_result).result; /*แบบเก่า*/
|
||||
//profileId = JsonConvert.DeserializeAnonymousType(_result, new { result = "" }).result; /*แบบใหม่*/
|
||||
}
|
||||
if (recv.Educations != null)
|
||||
|
||||
if (profile.ChangeNames.Count > 0)
|
||||
{
|
||||
var apiUrlEdu = $"{_configuration["API"]}/org/profile/educations";
|
||||
var apiUrlChgName = $"{_baseAPI}/org/profile/changeName";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var edu in recv.Educations)
|
||||
foreach (var chg in profile.ChangeNames)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlChgName, new
|
||||
{
|
||||
profileId = profileId,
|
||||
prefixId = chg.Prefix,
|
||||
prefix = chg.Prefix,
|
||||
firstName = chg.FirstName,
|
||||
lastName = chg.LastName,
|
||||
status = chg.Status,
|
||||
documentId = chg.Document,
|
||||
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (profile.FatherHistory.Count > 0)
|
||||
{
|
||||
var apiUrlFather = $"{_baseAPI}/org/profile/family/father";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var father in profile.FatherHistory)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlFather, new
|
||||
{
|
||||
profileId = profileId,
|
||||
fatherPrefix = father.Prefix,//ส่งคำนำหน้าไปแทน
|
||||
fatherFirstName = father.FirstName,
|
||||
fatherLastName = father.LastName,
|
||||
fatherCareer = father.Career,
|
||||
fatherCitizenId = (String?)null,
|
||||
fatherLive = false,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (profile.MotherHistory.Count > 0)
|
||||
{
|
||||
var apiUrlMother = $"{_baseAPI}/org/profile/family/mother";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var mother in profile.MotherHistory)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlMother, new
|
||||
{
|
||||
profileId = profileId,
|
||||
motherPrefix = mother.Prefix,
|
||||
motherFirstName = mother.FirstName,
|
||||
motherLastName = mother.LastName,
|
||||
motherCareer = mother.Career,
|
||||
motherCitizenId = (String?)null,
|
||||
motherLive = false,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (profile.CoupleHistory.Count > 0)
|
||||
{
|
||||
var apiUrlCouple = $"{_baseAPI}/org/profile/family/couple";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var couple in profile.CoupleHistory)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlCouple, new
|
||||
{
|
||||
profileId = profileId,
|
||||
couplePrefix = couple.Prefix,
|
||||
coupleFirstName = couple.FirstName,
|
||||
coupleLastName = couple.LastName,
|
||||
coupleLastNameOld = (String?)null,
|
||||
coupleCareer = couple.Career,
|
||||
coupleCitizenId = (String?)null,
|
||||
coupleLive = false,
|
||||
relationship = (String?)null,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (profile.Childrens.Count > 0)
|
||||
{
|
||||
var apiUrlChild = $"{_baseAPI}/org/profile/children";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var children in profile.Childrens)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlChild, new
|
||||
{
|
||||
profileId = profileId,
|
||||
childrenCareer = children.ChildrenCareer,
|
||||
childrenFirstName = children.ChildrenFirstName,
|
||||
childrenLastName = children.ChildrenLastName,
|
||||
childrenPrefix = children.ChildrenPrefix,
|
||||
childrenLive = true,
|
||||
childrenCitizenId = (String?)null,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (profile.Educations.Count > 0)
|
||||
{
|
||||
var apiUrlEdu = $"{_baseAPI}/org/profile/educations";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var edu in profile.Educations)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlEdu, new
|
||||
{
|
||||
profileId = profileId,
|
||||
country = edu.Country == null ? string.Empty : edu.Country,
|
||||
degree = edu.Degree == null ? string.Empty : edu.Degree,
|
||||
duration = edu.Duration == null ? string.Empty : edu.Duration,
|
||||
durationYear = edu.DurationYear == null ? 0 : edu.DurationYear,
|
||||
field = edu.Field == null ? string.Empty : edu.Field,
|
||||
finishDate = edu.FinishDate == null ? (DateTime?)null : edu.FinishDate,
|
||||
fundName = edu.FundName == null ? string.Empty : edu.FundName,
|
||||
gpa = edu.Gpa == null ? string.Empty : edu.Gpa,
|
||||
institute = edu.Institute == null ? string.Empty : edu.Institute,
|
||||
other = edu.Other == null ? string.Empty : edu.Other,
|
||||
startDate = edu.StartDate == null ? (DateTime?)null : edu.StartDate,
|
||||
endDate = edu.EndDate == null ? (DateTime?)null : edu.EndDate,
|
||||
educationLevel = edu.EducationLevel == null ? string.Empty : edu.EducationLevel.Name,
|
||||
educationLevelId = string.Empty,
|
||||
country = edu.Country,
|
||||
degree = edu.Degree,
|
||||
duration = edu.Duration,
|
||||
durationYear = edu.DurationYear,
|
||||
field = edu.Field,
|
||||
finishDate = edu.FinishDate,
|
||||
fundName = edu.FundName,
|
||||
gpa = edu.Gpa,
|
||||
institute = edu.Institute,
|
||||
other = edu.Other,
|
||||
startDate = edu.StartDate,
|
||||
endDate = edu.EndDate,
|
||||
educationLevel = edu.EducationLevel,
|
||||
educationLevelId = string.Empty, //where in node
|
||||
positionPath = edu.PositionPath == null ? null : edu.PositionPath,
|
||||
positionPathId = string.Empty,
|
||||
isDate = edu.IsDate,
|
||||
isEducation = edu.IsEducation,
|
||||
note = string.Empty,
|
||||
positionPathId = string.Empty, //where in node
|
||||
isDate = false,
|
||||
isEducation = false,
|
||||
note = edu.Note,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (placementProfile.PlacementCertificates != null)
|
||||
|
||||
if (profile.Abilitys.Count > 0)
|
||||
{
|
||||
var apiUrlCer = $"{_configuration["API"]}/org/profile/certificate";
|
||||
var apiUrlAbility = $"{_baseAPI}/org/profile/ability";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var cer in placementProfile.PlacementCertificates)
|
||||
foreach (var ability in profile.Abilitys)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlAbility, new
|
||||
{
|
||||
profileId = profileId,
|
||||
remark = ability.Remark,
|
||||
detail = ability.Detail,
|
||||
reference = ability.Reference,
|
||||
dateStart = ability.DateStart,
|
||||
dateEnd = ability.DateEnd,
|
||||
field = ability.Field,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (profile.Disciplines.Count > 0)
|
||||
{
|
||||
var apiUrlDisc = $"{_baseAPI}/org/profile/discipline";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var discipline in profile.Disciplines)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlDisc, new
|
||||
{
|
||||
profileId = profileId,
|
||||
date = discipline.Date,
|
||||
level = discipline.Level,
|
||||
detail = discipline.Detail,
|
||||
refCommandDate = discipline.RefCommandDate,
|
||||
refCommandNo = discipline.RefCommandNo,
|
||||
unStigma = (String?)null,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (profile.Leaves.Count > 0)
|
||||
{
|
||||
var apiUrlLeave = $"{_baseAPI}/org/profile/leave";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var leave in profile.Leaves)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlLeave, new
|
||||
{
|
||||
profileId = profileId,
|
||||
leaveTypeId = leave.TypeLeave,//ส่งชื่อประเภทการลาไปแทน
|
||||
dateLeaveStart = leave.DateStartLeave,
|
||||
dateLeaveEnd = leave.DateEndLeave,
|
||||
leaveDays = leave.SumLeave,
|
||||
leaveCount = leave.NumLeave,
|
||||
totalLeave = leave.TotalLeave,
|
||||
status = leave.Status,
|
||||
reason = leave.Reason,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (profile.Dutys.Count > 0)
|
||||
{
|
||||
var apiUrlDuty = $"{_baseAPI}/org/profile/duty";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var duty in profile.Dutys)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlDuty, new
|
||||
{
|
||||
profileId = profileId,
|
||||
dateStart = duty.DateStart,
|
||||
dateEnd = duty.DateEnd,
|
||||
detail = duty.Detail,
|
||||
reference = duty.Reference,
|
||||
refCommandDate = (String?)null,
|
||||
refCommandNo = (String?)null,
|
||||
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (profile.Salaries.Count > 0)
|
||||
{
|
||||
var apiUrlSalary = $"{_baseAPI}/org/profile/salary";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var salary in profile.Salaries)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
|
||||
{
|
||||
profileId = profileId,
|
||||
date = salary.Date,
|
||||
amount = salary.Amount,
|
||||
positionSalaryAmount = salary.PositionSalaryAmount,
|
||||
mouthSalaryAmount = salary.MouthSalaryAmount,
|
||||
posNo = salary.PosNoName,
|
||||
position = salary.PositionName,
|
||||
positionLine = salary.PositionLineName,
|
||||
positionPathSide = salary.PositionPathSideName,
|
||||
positionExecutive = salary.PositionExecutiveName,
|
||||
positionType = salary.PositionTypeName,
|
||||
positionLevel = salary.PositionLevelName,
|
||||
refCommandNo = salary.RefCommandNo,
|
||||
templateDoc = salary.SalaryRef,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (profile.Nopaids.Count > 0)
|
||||
{
|
||||
var apiUrlNopaid = $"{_baseAPI}/org/profile/nopaid";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var nopaid in profile.Nopaids)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlNopaid, new
|
||||
{
|
||||
profileId = profileId,
|
||||
date = nopaid.Date,
|
||||
detail = nopaid.Detail,
|
||||
reference = nopaid.Reference,
|
||||
refCommandDate = nopaid.Date ?? null, //ไม่มีฟิลด์ เอกสารอ้างอิง (ลงวันที่)
|
||||
refCommandNo = string.Empty, //ไม่มีฟิลด์ เอกสารอ้างอิง (เลขที่คำสั่ง)
|
||||
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (profile.Certificates.Count > 0)
|
||||
{
|
||||
var apiUrlCer = $"{_baseAPI}/org/profile/certificate";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var cer in profile.Certificates)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlCer, new
|
||||
{
|
||||
profileId = profileId,
|
||||
expireDate = cer.ExpireDate == null ? (DateTime?)null : cer.ExpireDate,
|
||||
issueDate = cer.IssueDate == null ? (DateTime?)null : cer.IssueDate,
|
||||
certificateNo = cer.CertificateNo == null ? string.Empty : cer.CertificateNo,
|
||||
certificateType = cer.CertificateType == null ? string.Empty : cer.CertificateType,
|
||||
issuer = cer.Issuer == null ? string.Empty : cer.Issuer,
|
||||
expireDate = cer.ExpireDate,
|
||||
issueDate = cer.IssueDate,
|
||||
certificateNo = cer.CertificateNo,
|
||||
certificateType = cer.CertificateType,
|
||||
issuer = cer.Issuer,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
var apiUrlSalary = $"{_configuration["API"]}/org/profile/salary";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
|
||||
{
|
||||
profileId = profileId,
|
||||
date = command.CommandAffectDate == null ? (DateTime?)null : command.CommandAffectDate,
|
||||
amount = recv.Amount == null ? null : recv.Amount,
|
||||
positionSalaryAmount = placementProfile.PositionSalaryAmount == null ? null : placementProfile.PositionSalaryAmount,
|
||||
mouthSalaryAmount = placementProfile.MouthSalaryAmount == null ? null : placementProfile.MouthSalaryAmount,
|
||||
posNo = placementProfile.PosNumber == null ? string.Empty : placementProfile.PosNumber.ToString(),
|
||||
position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName,
|
||||
positionLine = string.Empty,
|
||||
positionPathSide = string.Empty,
|
||||
positionExecutive = string.Empty,
|
||||
positionType = placementProfile.posTypeName == null ? string.Empty : placementProfile.posTypeName,
|
||||
positionLevel = placementProfile.PositionLevel == null ? string.Empty : placementProfile.PositionLevel.Name,
|
||||
refCommandNo = string.Empty,
|
||||
templateDoc = string.Empty,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
placementProfile.PlacementStatus = "CONTAIN";
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
if (profile.Trainings.Count > 0)
|
||||
{
|
||||
var apiUrlTrain = $"{_baseAPI}/org/profile/training";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var train in profile.Trainings)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlTrain, new
|
||||
{
|
||||
profileId = profileId,
|
||||
startDate = train.StartDate,
|
||||
endDate = train.EndDate,
|
||||
numberOrder = train.NumberOrder,
|
||||
topic = train.Topic,
|
||||
place = train.Place,
|
||||
dateOrder = train.DateOrder,
|
||||
department = train.StartDate,
|
||||
duration = train.Duration,
|
||||
name = train.Name,
|
||||
yearly = train.Yearly,
|
||||
isDate = train.IsDate,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (profile.Insignias.Count > 0)
|
||||
{
|
||||
var apiUrlInsig = $"{_baseAPI}/org/profile/insignia";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var insignia in profile.Insignias)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlInsig, new
|
||||
{
|
||||
profileId = profileId,
|
||||
year = insignia.Year,
|
||||
no = insignia.No,
|
||||
volume = insignia.Volume,
|
||||
section = insignia.Section,
|
||||
page = insignia.Page,
|
||||
receiveDate = insignia.ReceiveDate,
|
||||
insigniaId = insignia.InsigniaType, //ส่งชื่อเครื่องราชฯไปแทน
|
||||
dateAnnounce = insignia.DateAnnounce,
|
||||
issue = insignia.Issue,
|
||||
volumeNo = insignia.VolumeNo,
|
||||
refCommandDate = insignia.RefCommandDate,
|
||||
refCommandNo = insignia.RefCommandNo,
|
||||
note = insignia.Note,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (profile.Honors.Count > 0)
|
||||
{
|
||||
var apiUrlHonor = $"{_baseAPI}/org/profile/honor";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var honor in profile.Honors)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlHonor, new
|
||||
{
|
||||
profileId = profileId,
|
||||
detail = honor.Detail,
|
||||
issueDate = honor.IssueDate,
|
||||
issuer = honor.Issuer,
|
||||
refCommandDate = (String?)null,
|
||||
refCommandNo = (String?)null,
|
||||
isDate = honor.IsDate,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (profile.Assessments.Count > 0)
|
||||
{
|
||||
var apiUrlAssess = $"{_baseAPI}/org/profile/assessments";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var assess in profile.Assessments)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlAssess, new
|
||||
{
|
||||
profileId = profileId,
|
||||
name = assess.Name,
|
||||
date = assess.Date,
|
||||
point1 = assess.Point1,
|
||||
point1Total = assess.Point1Total,
|
||||
point2 = assess.Point2,
|
||||
point2Total = assess.Point2Total,
|
||||
pointSum = assess.PointSum,
|
||||
pointSumTotal = assess.PointSumTotal,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (profile.Others.Count > 0)
|
||||
{
|
||||
var apiUrlOther = $"{_baseAPI}/org/profile/other";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
foreach (var other in profile.Others)
|
||||
{
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOther, new
|
||||
{
|
||||
profileId = profileId,
|
||||
detail = other.Detail,
|
||||
date = other.Date,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
//profile.PlacementStatus = "CONTAIN";
|
||||
//await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
//return "";
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -101,6 +101,27 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
protected async Task<bool> PostExternalAPIBooleanAsync(string apiPath, string accessToken, object? body)
|
||||
{
|
||||
try
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(body);
|
||||
var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");
|
||||
stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
|
||||
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken.Replace("Bearer ", ""));
|
||||
var _res = await client.PostAsync(apiPath, stringContent);
|
||||
return _res.IsSuccessStatusCode;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public async Task<Guid> GetProfileOrganizationAsync(string citizenId)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
get
|
||||
{
|
||||
if (UserId != null || UserId != "")
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), AccessToken);
|
||||
else
|
||||
return Guid.Empty;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
get
|
||||
{
|
||||
if (UserId != null || UserId != "")
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), AccessToken);
|
||||
else
|
||||
return Guid.Empty;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
get
|
||||
{
|
||||
if (UserId != null || UserId != "")
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), AccessToken);
|
||||
else
|
||||
return Guid.Empty;
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(userId, AccessToken ?? "");
|
||||
var profile_id = profile == null ? Guid.Empty : profile.Id;
|
||||
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile_id);
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile_id, AccessToken);
|
||||
var approver = string.Empty;
|
||||
var list = new List<OrganizationApproverResponse>();
|
||||
if (rootOc != null)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
get
|
||||
{
|
||||
if (UserId != null || UserId != "")
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), AccessToken);
|
||||
else
|
||||
return Guid.Empty;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
get
|
||||
{
|
||||
if (UserId != null || UserId != "")
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), AccessToken);
|
||||
else
|
||||
return Guid.Empty;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
get
|
||||
{
|
||||
if (UserId != null || UserId != "")
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), AccessToken);
|
||||
else
|
||||
return Guid.Empty;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
get
|
||||
{
|
||||
if (UserId != null || UserId != "")
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), AccessToken);
|
||||
else
|
||||
return Guid.Empty;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
|||
get
|
||||
{
|
||||
if (UserId != null || UserId != "")
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), AccessToken);
|
||||
else
|
||||
return Guid.Empty;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,31 +92,43 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateDutyTimeAsync(Guid profileId, Guid roundId, DateTime effectiveDate)
|
||||
public async Task<bool> UpdateDutyTimeAsync(Guid profileId, Guid roundId, DateTime effectiveDate, string? accessToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var profile = await _dbContext.Set<Profile>()
|
||||
.AsQueryable()
|
||||
.Include(x => x.Prefix)
|
||||
.FirstOrDefaultAsync(x => x.Id == profileId);
|
||||
var apiPath = $"{_configuration["API"]}/org/dotnet/update-dutytime";
|
||||
|
||||
if (profile == null)
|
||||
var body = new
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
}
|
||||
else
|
||||
{
|
||||
var fullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}";
|
||||
Console.WriteLine(fullName);
|
||||
EffevtiveDate = effectiveDate,
|
||||
RoundId = roundId,
|
||||
ProfileId = profileId
|
||||
};
|
||||
|
||||
profile.DutyTimeId = roundId;
|
||||
profile.DutyTimeEffectiveDate = effectiveDate;
|
||||
var apiResult = await PostExternalAPIBooleanAsync(apiPath, accessToken ?? "", body);
|
||||
|
||||
await UpdateAsync(profile);
|
||||
return apiResult;
|
||||
//var profile = await _dbContext.Set<Profile>()
|
||||
// .AsQueryable()
|
||||
// .Include(x => x.Prefix)
|
||||
// .FirstOrDefaultAsync(x => x.Id == profileId);
|
||||
|
||||
return true;
|
||||
}
|
||||
//if (profile == null)
|
||||
//{
|
||||
// throw new Exception(GlobalMessages.DataNotFound);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// var fullName = $"{profile.Prefix.Name}{profile.FirstName} {profile.LastName}";
|
||||
// Console.WriteLine(fullName);
|
||||
|
||||
// profile.DutyTimeId = roundId;
|
||||
// profile.DutyTimeEffectiveDate = effectiveDate;
|
||||
|
||||
// await UpdateAsync(profile);
|
||||
|
||||
// return true;
|
||||
//}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -124,16 +136,21 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<List<Profile>> GetProfileWithKeycloak()
|
||||
public async Task<List<GetProfileByKeycloakIdDto>> GetProfileWithKeycloak(string? accessToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await _dbContext.Set<Profile>().AsQueryable()
|
||||
.Where(x => x.ProfileType == "officer")
|
||||
.Where(x => x.KeycloakId != null)
|
||||
.ToListAsync();
|
||||
var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak";
|
||||
|
||||
return data;
|
||||
var apiResult = await GetExternalAPIAsync(apiPath, accessToken ?? "");
|
||||
if (apiResult != null)
|
||||
{
|
||||
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdResultDto>(apiResult);
|
||||
if (raw != null)
|
||||
return raw.Result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -193,28 +210,51 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<List<Profile>> SearchProfileEmployee(string? citizenId, string? firstName, string? lastName)
|
||||
public async Task<List<SearchProfileDto>> SearchProfileEmployee(string? citizenId, string? firstName, string? lastName, string accessToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = _dbContext.Set<Profile>().AsQueryable()
|
||||
.Where(x => x.ProfileType == "employee");
|
||||
var apiPath = $"{_configuration["API"]}/org/dotnet/search-employee";
|
||||
var body = new
|
||||
{
|
||||
citizenId = citizenId,
|
||||
firstName = firstName,
|
||||
lastName = lastName
|
||||
};
|
||||
|
||||
var profiles = new List<SearchProfileDto>();
|
||||
|
||||
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body);
|
||||
if (apiResult != null)
|
||||
{
|
||||
var raw = JsonConvert.DeserializeObject<SearchProfileResultDto>(apiResult);
|
||||
if (raw != null && raw.Result != null)
|
||||
{
|
||||
profiles.AddRange(raw.Result);
|
||||
}
|
||||
}
|
||||
|
||||
return profiles;
|
||||
|
||||
|
||||
if (citizenId != null)
|
||||
data = data.Where(x => x.CitizenId!.Contains(citizenId));
|
||||
|
||||
if (firstName != null)
|
||||
data = data.Where(x => x.FirstName!.Contains(firstName));
|
||||
|
||||
if (lastName != null)
|
||||
data = data.Where(x => x.LastName!.Contains(lastName));
|
||||
|
||||
data = data.Include(x => x.Prefix);
|
||||
//.Include(x => x.PosNoEmployee);
|
||||
//var data = _dbContext.Set<Profile>().AsQueryable()
|
||||
// .Where(x => x.ProfileType == "employee");
|
||||
|
||||
|
||||
return await data.ToListAsync();
|
||||
//if (citizenId != null)
|
||||
// data = data.Where(x => x.CitizenId!.Contains(citizenId));
|
||||
|
||||
//if (firstName != null)
|
||||
// data = data.Where(x => x.FirstName!.Contains(firstName));
|
||||
|
||||
//if (lastName != null)
|
||||
// data = data.Where(x => x.LastName!.Contains(lastName));
|
||||
|
||||
//data = data.Include(x => x.Prefix);
|
||||
////.Include(x => x.PosNoEmployee);
|
||||
|
||||
|
||||
//return await data.ToListAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -222,17 +262,22 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public string GetUserFullName(Guid keycloakId)
|
||||
public string GetUserFullName(Guid keycloakId, string? accessToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = _dbContext.Set<Profile>().AsQueryable()
|
||||
.Include(x => x.Prefix)
|
||||
.Where(x => x.KeycloakId == keycloakId)
|
||||
.Select(x => $"{x.Prefix!.Name}{x.FirstName} {x.LastName}")
|
||||
.FirstOrDefault();
|
||||
var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak";
|
||||
|
||||
var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "");
|
||||
if (apiResult.Result != null)
|
||||
{
|
||||
var raw = JsonConvert.DeserializeObject<GetUserFullNameResultDto>(apiResult.Result);
|
||||
if (raw != null)
|
||||
return raw.Result;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
|
||||
return data ?? "-";
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -240,21 +285,34 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public Guid GetUserOCId(Guid keycloakId)
|
||||
public Guid GetUserOCId(Guid keycloakId, string? accessToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = _dbContext.Set<ProfilePosition>()
|
||||
.Include(x => x.Profile)
|
||||
.Include(x => x.OrganizationPosition)
|
||||
.ThenInclude(x => x.Organization)
|
||||
.Where(x => x.Profile!.KeycloakId == keycloakId)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (data == null)
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
var apiPath = $"{_configuration["API"]}/org/dotnet/user-oc/{keycloakId}";
|
||||
|
||||
return data.OrganizationPosition!.Organization!.Id;
|
||||
var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "");
|
||||
if (apiResult.Result != null)
|
||||
{
|
||||
var raw = JsonConvert.DeserializeObject<GetUserOCIdResultDto>(apiResult.Result);
|
||||
if (raw != null)
|
||||
return raw.Result!.RootId;
|
||||
}
|
||||
|
||||
return Guid.Empty;
|
||||
|
||||
//var data = _dbContext.Set<ProfilePosition>()
|
||||
// .Include(x => x.Profile)
|
||||
// .Include(x => x.OrganizationPosition)
|
||||
// .ThenInclude(x => x.Organization)
|
||||
// .Where(x => x.Profile!.KeycloakId == keycloakId)
|
||||
// .FirstOrDefault();
|
||||
|
||||
//if (data == null)
|
||||
// throw new Exception(GlobalMessages.DataNotFound);
|
||||
|
||||
//return data.OrganizationPosition!.Organization!.Id;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -262,14 +320,26 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public Guid? GetRootOcId(Guid ocId)
|
||||
public Guid? GetRootOcId(Guid ocId, string? accessToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = _dbContext.Set<OrganizationEntity>()
|
||||
.FirstOrDefault(o => o.Id == ocId);
|
||||
var apiPath = $"{_configuration["API"]}/org/dotnet/root-oc/{ocId}";
|
||||
|
||||
return data == null ? Guid.Empty : data.OrganizationAgencyId;
|
||||
var apiResult = GetExternalAPIAsync(apiPath, accessToken ?? "");
|
||||
if (apiResult.Result != null)
|
||||
{
|
||||
var raw = JsonConvert.DeserializeObject<GetRootOCIdResultDto>(apiResult.Result);
|
||||
if (raw != null)
|
||||
return raw.Result;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
//var data = _dbContext.Set<OrganizationEntity>()
|
||||
// .FirstOrDefault(o => o.Id == ocId);
|
||||
|
||||
//return data == null ? Guid.Empty : data.OrganizationAgencyId;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
namespace BMA.EHR.Application.Responses.Profiles
|
||||
{
|
||||
public class GetListProfileByKeycloakIdResultDto
|
||||
{
|
||||
public string Message { get; set; } = string.Empty;
|
||||
|
||||
public int Status { get; set; } = -1;
|
||||
|
||||
public List<GetProfileByKeycloakIdDto> Result { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
|
@ -29,6 +29,12 @@ namespace BMA.EHR.Application.Responses.Profiles
|
|||
|
||||
public List<ProfileSalary> Salaries { get; set; } = new();
|
||||
|
||||
public Guid? Keycloak { get; set; }
|
||||
|
||||
public string? PosNo { get; set; }
|
||||
|
||||
public string? PosNoEmployee { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class PosLevel
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
namespace BMA.EHR.Application.Responses.Profiles
|
||||
{
|
||||
public class GetRootOCIdResultDto
|
||||
{
|
||||
public string Message { get; set; } = string.Empty;
|
||||
|
||||
public int Status { get; set; } = -1;
|
||||
|
||||
public Guid Result { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
namespace BMA.EHR.Application.Responses.Profiles
|
||||
{
|
||||
public class GetUserFullNameResultDto
|
||||
{
|
||||
public string Message { get; set; } = string.Empty;
|
||||
|
||||
public int Status { get; set; } = -1;
|
||||
|
||||
public string Result { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
29
BMA.EHR.Application/Responses/Profiles/GetUserOCIdDto.cs
Normal file
29
BMA.EHR.Application/Responses/Profiles/GetUserOCIdDto.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
namespace BMA.EHR.Application.Responses.Profiles
|
||||
{
|
||||
public class GetUserOCIdDto
|
||||
{
|
||||
public Guid ProfileId { get; set; }
|
||||
|
||||
public string Prefix { get; set; } = string.Empty;
|
||||
|
||||
public string Rank { get; set; } = string.Empty;
|
||||
|
||||
public string Avatar { get; set; } = string.Empty;
|
||||
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
|
||||
public string CitizenId { get; set; } = string.Empty;
|
||||
|
||||
public DateTime BirthDate { get; set; } = DateTime.MinValue;
|
||||
|
||||
public string Position { get; set; } = string.Empty;
|
||||
|
||||
public Guid RootId { get; set; }
|
||||
|
||||
public string Root { get; set; } = string.Empty;
|
||||
|
||||
public string RootShortName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
namespace BMA.EHR.Application.Responses.Profiles
|
||||
{
|
||||
public class GetUserOCIdResultDto
|
||||
{
|
||||
public string Message { get; set; } = string.Empty;
|
||||
|
||||
public int Status { get; set; } = -1;
|
||||
|
||||
public GetUserOCIdDto? Result { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -8,5 +8,13 @@
|
|||
public string? FirstName { get; set; }
|
||||
public string? LastName { get; set; }
|
||||
public string? CitizenId { get; set; }
|
||||
|
||||
public Guid? Keycloak { get; set; }
|
||||
|
||||
public string? PosNoEmployee { get; set; }
|
||||
|
||||
public string? Oc { get; set; }
|
||||
|
||||
public string? PosNo { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
get
|
||||
{
|
||||
if (UserId != null || UserId != "")
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), AccessToken);
|
||||
else
|
||||
return Guid.Empty;
|
||||
}
|
||||
|
|
@ -687,7 +687,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
.Select(d => new CheckInHistoryForAdminDto
|
||||
{
|
||||
Id = d.Id,
|
||||
FullName = _userProfileRepository.GetUserFullName(d.KeycloakUserId),
|
||||
FullName = _userProfileRepository.GetUserFullName(d.KeycloakUserId, AccessToken),
|
||||
|
||||
CheckInDate = d.CheckIn.Date,
|
||||
CheckInTime = d.CheckIn.ToString("HH:mm:ss"),
|
||||
|
|
@ -773,7 +773,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var result = new CheckInDetailForAdminDto
|
||||
{
|
||||
Id = d.Id,
|
||||
FullName = _userProfileRepository.GetUserFullName(d.KeycloakUserId),
|
||||
FullName = _userProfileRepository.GetUserFullName(d.KeycloakUserId, AccessToken),
|
||||
|
||||
CheckInDate = d.CheckIn.Date,
|
||||
CheckInTime = d.CheckIn.ToString("HH:mm"),
|
||||
|
|
@ -873,7 +873,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
.Select(d => new CheckInProcessHistoryForAdminDto
|
||||
{
|
||||
Id = d.Id,
|
||||
FullName = _userProfileRepository.GetUserFullName(d.KeycloakUserId),
|
||||
FullName = _userProfileRepository.GetUserFullName(d.KeycloakUserId, AccessToken),
|
||||
|
||||
CheckInDate = d.CheckIn.Date,
|
||||
CheckInTime = d.CheckIn.ToString("HH:mm"),
|
||||
|
|
@ -1387,7 +1387,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var result = new CheckInDetailForAdminDto
|
||||
{
|
||||
Id = d.Id,
|
||||
FullName = _userProfileRepository.GetUserFullName(d.KeycloakUserId),
|
||||
FullName = _userProfileRepository.GetUserFullName(d.KeycloakUserId, AccessToken),
|
||||
|
||||
CheckInDate = d.CheckIn.Date,
|
||||
CheckInTime = d.CheckIn.ToString("HH:mm"),
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
get
|
||||
{
|
||||
if (UserId != null || UserId != "")
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), AccessToken);
|
||||
else
|
||||
return Guid.Empty;
|
||||
}
|
||||
|
|
@ -113,7 +113,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync(data.KeycloakUserId,
|
||||
data.Type.Id);
|
||||
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
|
||||
var approver = string.Empty;
|
||||
if (rootOc != null)
|
||||
{
|
||||
|
|
@ -164,7 +164,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
|
||||
var approver = string.Empty;
|
||||
if (rootOc != null)
|
||||
{
|
||||
|
|
@ -208,7 +208,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
|
||||
var approver = string.Empty;
|
||||
if (rootOc != null)
|
||||
{
|
||||
|
|
@ -259,7 +259,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
|
||||
var approver = string.Empty;
|
||||
if (rootOc != null)
|
||||
{
|
||||
|
|
@ -342,7 +342,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
|
||||
var approver = string.Empty;
|
||||
if (rootOc != null)
|
||||
{
|
||||
|
|
@ -390,7 +390,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
|
||||
var approver = string.Empty;
|
||||
if (rootOc != null)
|
||||
{
|
||||
|
|
@ -445,7 +445,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
|
||||
var approver = string.Empty;
|
||||
if (rootOc != null)
|
||||
{
|
||||
|
|
@ -487,7 +487,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
|
||||
var approver = string.Empty;
|
||||
if (rootOc != null)
|
||||
{
|
||||
|
|
@ -542,7 +542,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
|
||||
var approver = string.Empty;
|
||||
if (rootOc != null)
|
||||
{
|
||||
|
|
@ -692,7 +692,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var fullName = $"{profile!.Prefix}{profile!.FirstName} {profile!.LastName}";
|
||||
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
|
||||
var approver = string.Empty;
|
||||
if (rootOc != null)
|
||||
{
|
||||
|
|
@ -749,7 +749,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
try
|
||||
{
|
||||
//var profile = await _userProfileRepository.SearchProfile(null, null, null);
|
||||
var profile = await _userProfileRepository.GetProfileWithKeycloak();
|
||||
var profile = await _userProfileRepository.GetProfileWithKeycloak(AccessToken);
|
||||
|
||||
var count = 1;
|
||||
var employees = new List<dynamic>();
|
||||
|
|
@ -761,7 +761,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var sickType = await _leaveTypeRepository.GetLeaveTypeByCodeAsync("LV-001");
|
||||
if (sickType == null)
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
var sickDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
var sickDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
sickType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
|
@ -769,7 +769,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var personalType = await _leaveTypeRepository.GetLeaveTypeByCodeAsync("LV-002");
|
||||
if (personalType == null)
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
var personalDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
var personalDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
personalType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
|
@ -777,7 +777,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var maternityType = await _leaveTypeRepository.GetLeaveTypeByCodeAsync("LV-003");
|
||||
if (maternityType == null)
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
var maternityDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
var maternityDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
maternityType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
|
@ -785,7 +785,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var wifeType = await _leaveTypeRepository.GetLeaveTypeByCodeAsync("LV-004");
|
||||
if (wifeType == null)
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
var wifeDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
var wifeDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
wifeType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
|
@ -793,7 +793,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var restType = await _leaveTypeRepository.GetLeaveTypeByCodeAsync("LV-005");
|
||||
if (restType == null)
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
var restDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
var restDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
restType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
|
@ -801,7 +801,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var ordainType = await _leaveTypeRepository.GetLeaveTypeByCodeAsync("LV-006");
|
||||
if (ordainType == null)
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
var ordainDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
var ordainDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
ordainType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
|
@ -809,7 +809,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var absentType = await _leaveTypeRepository.GetLeaveTypeByCodeAsync("LV-007");
|
||||
if (absentType == null)
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
var absentDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
var absentDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
absentType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
|
@ -817,7 +817,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var studyType = await _leaveTypeRepository.GetLeaveTypeByCodeAsync("LV-008");
|
||||
if (studyType == null)
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
var studyDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
var studyDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
studyType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
|
@ -825,7 +825,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var agencyType = await _leaveTypeRepository.GetLeaveTypeByCodeAsync("LV-009");
|
||||
if (agencyType == null)
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
var agencyDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
var agencyDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
agencyType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
|
@ -833,7 +833,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var coupleType = await _leaveTypeRepository.GetLeaveTypeByCodeAsync("LV-010");
|
||||
if (coupleType == null)
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
var coupleDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
var coupleDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
coupleType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
|
@ -841,12 +841,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var therapyType = await _leaveTypeRepository.GetLeaveTypeByCodeAsync("LV-011");
|
||||
if (therapyType == null)
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
var therapyDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
var therapyDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
therapyType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
||||
var timeStamps = await _processUserTimeStampRepository.GetTimeStampHistoryByRangeForUserAsync(p.KeycloakId ?? Guid.Empty,
|
||||
var timeStamps = await _processUserTimeStampRepository.GetTimeStampHistoryByRangeForUserAsync(p.Keycloak ?? Guid.Empty,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
||||
|
|
@ -890,10 +890,10 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var emp = new
|
||||
{
|
||||
no = count,
|
||||
fullName = _userProfileRepository.GetUserFullName(p.KeycloakId ?? Guid.Empty),
|
||||
position = p.Position == null ? "" : p.Position.Name,
|
||||
positionLevel = p.PositionLevel == null ? "" : p.PositionLevel.Name,
|
||||
posNo = p.PosNo == null ? "" : p.PosNo.Name,
|
||||
fullName = _userProfileRepository.GetUserFullName(p.Keycloak ?? Guid.Empty, AccessToken),
|
||||
position = p.Position == null ? "" : p.Position,
|
||||
positionLevel = p.PosLevel == null ? "" : p.PosLevel.PosLevelName,
|
||||
posNo = p.PosNo ?? "",
|
||||
reason = "",
|
||||
|
||||
sickDayCount = sickDayCount,
|
||||
|
|
@ -966,7 +966,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
try
|
||||
{
|
||||
var profile = await _userProfileRepository.SearchProfileEmployee(null, null, null);
|
||||
var profile = await _userProfileRepository.SearchProfileEmployee(null, null, null, AccessToken ?? "");
|
||||
var count = 1;
|
||||
var employees = new List<dynamic>();
|
||||
|
||||
|
|
@ -977,11 +977,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var sickType = await _leaveTypeRepository.GetLeaveTypeByCodeAsync("LV-001");
|
||||
if (sickType == null)
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
var sickDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
var sickDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
sickType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
var sickCount = await _leaveRequestRepository.GetCountApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
|
||||
var sickCount = await _leaveRequestRepository.GetCountApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
sickType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
|
@ -989,12 +990,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var personalType = await _leaveTypeRepository.GetLeaveTypeByCodeAsync("LV-002");
|
||||
if (personalType == null)
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
var personalDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
var personalDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
personalType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
||||
var personalCount = await _leaveRequestRepository.GetCountApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
var personalCount = await _leaveRequestRepository.GetCountApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
personalType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
|
@ -1002,7 +1003,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var maternityType = await _leaveTypeRepository.GetLeaveTypeByCodeAsync("LV-003");
|
||||
if (maternityType == null)
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
var maternityDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
var maternityDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
maternityType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
|
@ -1010,7 +1011,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var wifeType = await _leaveTypeRepository.GetLeaveTypeByCodeAsync("LV-004");
|
||||
if (wifeType == null)
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
var wifeDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
var wifeDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
wifeType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
|
@ -1018,7 +1019,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var restType = await _leaveTypeRepository.GetLeaveTypeByCodeAsync("LV-005");
|
||||
if (restType == null)
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
var restDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
var restDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
restType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
|
@ -1026,12 +1027,12 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var ordainType = await _leaveTypeRepository.GetLeaveTypeByCodeAsync("LV-006");
|
||||
if (ordainType == null)
|
||||
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
|
||||
var ordainDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.KeycloakId ?? Guid.Empty,
|
||||
var ordainDayCount = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRangeForUser(p.Keycloak ?? Guid.Empty,
|
||||
ordainType.Id,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
||||
var timeStamps = await _processUserTimeStampRepository.GetTimeStampHistoryByRangeForUserAsync(p.KeycloakId ?? Guid.Empty,
|
||||
var timeStamps = await _processUserTimeStampRepository.GetTimeStampHistoryByRangeForUserAsync(p.Keycloak ?? Guid.Empty,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
||||
|
|
@ -1074,7 +1075,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var emp = new
|
||||
{
|
||||
no = count,
|
||||
fullName = _userProfileRepository.GetUserFullName(p.KeycloakId ?? Guid.Empty),
|
||||
fullName = _userProfileRepository.GetUserFullName(p.Keycloak ?? Guid.Empty, AccessToken),
|
||||
posNo = p.PosNoEmployee ?? "",
|
||||
reason = "",
|
||||
|
||||
|
|
@ -1137,7 +1138,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
try
|
||||
{
|
||||
//var profile = await _userProfileRepository.SearchProfile(null, null, null);
|
||||
var profile = await _userProfileRepository.GetProfileWithKeycloak();
|
||||
var profile = await _userProfileRepository.GetProfileWithKeycloak(AccessToken);
|
||||
var date = req.StartDate.Date;
|
||||
|
||||
var holidays = await _holidayRepository.GetHolidayAsync(req.StartDate.Date, req.EndDate.Date);
|
||||
|
|
@ -1168,11 +1169,11 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
foreach (var p in profile)
|
||||
{
|
||||
|
||||
var keycloakUserId = p.KeycloakId ?? Guid.Empty;
|
||||
var keycloakUserId = p.Keycloak ?? Guid.Empty;
|
||||
|
||||
var timeStamps = await _processUserTimeStampRepository.GetTimestampByDateAsync(keycloakUserId, dd);
|
||||
|
||||
var fullName = _userProfileRepository.GetUserFullName(keycloakUserId);
|
||||
var fullName = _userProfileRepository.GetUserFullName(keycloakUserId, AccessToken);
|
||||
|
||||
|
||||
var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
get
|
||||
{
|
||||
if (UserId != null || UserId != "")
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!));
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), AccessToken);
|
||||
else
|
||||
return Guid.Empty;
|
||||
}
|
||||
|
|
@ -298,7 +298,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
|
||||
// add dear and oc_data
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
|
||||
var approver = string.Empty;
|
||||
if (rootOc != null)
|
||||
{
|
||||
|
|
@ -524,7 +524,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
|
||||
// add dear and oc_data
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
|
||||
var approver = string.Empty;
|
||||
if (rootOc != null)
|
||||
{
|
||||
|
|
@ -613,7 +613,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var lastSalary = profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault();
|
||||
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
|
||||
var approver = string.Empty;
|
||||
if (rootOc != null)
|
||||
{
|
||||
|
|
@ -1423,7 +1423,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
await _leaveRequestRepository.GetLastLeaveRequestByTypeForUserAsync(rawData.KeycloakUserId,
|
||||
rawData.Type.Id);
|
||||
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty);
|
||||
var rootOc = _userProfileRepository.GetRootOcId(profile.OcId ?? Guid.Empty, AccessToken);
|
||||
var approver = string.Empty;
|
||||
if (rootOc != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -55,12 +55,14 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
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!));
|
||||
return _userProfileRepository.GetUserOCId(Guid.Parse(UserId!), AccessToken);
|
||||
else
|
||||
return Guid.Empty;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue