บันทึกการลาลงทะเบียนประวัติ
This commit is contained in:
parent
92e298c745
commit
8b10a65d2a
1 changed files with 34 additions and 13 deletions
|
|
@ -1,4 +1,6 @@
|
|||
using System.Drawing;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http.Json;
|
||||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Application.Messaging;
|
||||
using BMA.EHR.Domain.Models.HR;
|
||||
|
|
@ -404,7 +406,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้");
|
||||
}
|
||||
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId,AccessToken);
|
||||
var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken);
|
||||
if (profile == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
|
|
@ -421,19 +423,38 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
|
||||
|
||||
// insert to profile leave
|
||||
var profileLeave = new ProfileLeave
|
||||
// var profileLeave = new ProfileLeave
|
||||
// {
|
||||
// DateStartLeave = rawData.LeaveStartDate,
|
||||
// DateEndLeave = rawData.LeaveEndDate,
|
||||
|
||||
// TotalLeave = rawData.LeaveTotal,
|
||||
// Status = "approve",
|
||||
// Reason = rawData.LeaveDetail,
|
||||
|
||||
// ProfileId = profile.Id, // change from profile object to id
|
||||
// TypeLeave = leaveType
|
||||
// };
|
||||
// _appDbContext.Set<ProfileLeave>().Add(profileLeave);
|
||||
var _baseAPI = _configuration["API"];
|
||||
var apiUrlSalary = $"{_baseAPI}/org/profile/leave";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
DateStartLeave = rawData.LeaveStartDate,
|
||||
DateEndLeave = rawData.LeaveEndDate,
|
||||
|
||||
TotalLeave = rawData.LeaveTotal,
|
||||
Status = "approve",
|
||||
Reason = rawData.LeaveDetail,
|
||||
|
||||
ProfileId = profile.Id, // change from profile object to id
|
||||
TypeLeave = leaveType
|
||||
};
|
||||
_appDbContext.Set<ProfileLeave>().Add(profileLeave);
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
|
||||
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
|
||||
{
|
||||
profileId = profile.Id,
|
||||
leaveTypeId = leaveType?.Id ?? null,
|
||||
dateLeaveStart = rawData.LeaveStartDate,
|
||||
dateLeaveEnd = rawData.LeaveEndDate,
|
||||
leaveDays = 0,//หน้า fe ไม่ได้ใช้
|
||||
leaveCount = 0,//หน้า fe ไม่ได้ใช้
|
||||
totalLeave = rawData.LeaveTotal,
|
||||
status = "approve",
|
||||
reason = rawData.LeaveDetail,
|
||||
});
|
||||
// var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
|
||||
// insert to process timestamp
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue