บันทึกผู้อนุมัติการลา โโยแปลง json ที่มาจาก FormData
This commit is contained in:
parent
885478f672
commit
28b573bfb8
2 changed files with 54 additions and 3 deletions
|
|
@ -20,6 +20,7 @@ using Swashbuckle.AspNetCore.Annotations;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Security.Policy;
|
using System.Security.Policy;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
|
|
||||||
namespace BMA.EHR.Leave.Service.Controllers
|
namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -170,7 +171,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
var leaveRequest = new LeaveRequest
|
var leaveRequest = new LeaveRequest
|
||||||
{
|
{
|
||||||
Type = leaveType,
|
Type = leaveType,
|
||||||
|
|
||||||
LeaveSubTypeName = req.LeaveSubTypeName,
|
LeaveSubTypeName = req.LeaveSubTypeName,
|
||||||
LeaveRange = req.LeaveRange,
|
LeaveRange = req.LeaveRange,
|
||||||
LeaveStartDate = req.LeaveStartDate,
|
LeaveStartDate = req.LeaveStartDate,
|
||||||
|
|
@ -366,6 +367,30 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
leaveRequest.PositionLevelName = profile.PosLevel == null ? "" : profile.PosLevel;
|
leaveRequest.PositionLevelName = profile.PosLevel == null ? "" : profile.PosLevel;
|
||||||
leaveRequest.OrganizationName = userOc;
|
leaveRequest.OrganizationName = userOc;
|
||||||
|
|
||||||
|
if (req.Approvers != null && req.Approvers != "")
|
||||||
|
{
|
||||||
|
//var jsonString = System.Text.Json.JsonSerializer.Deserialize<string>(req.Approvers ?? "");
|
||||||
|
//var fixedJson = req.Approvers.Replace("\\\"", "\"");
|
||||||
|
var approvers = JsonConvert.DeserializeObject<List<LeaveRequestApproverDto>>(req.Approvers);
|
||||||
|
if (approver != null)
|
||||||
|
{
|
||||||
|
foreach (var r in approvers!)
|
||||||
|
{
|
||||||
|
leaveRequest.Approvers.Add(new LeaveRequestApprover
|
||||||
|
{
|
||||||
|
Seq = r.Seq,
|
||||||
|
Prefix = r.Prefix,
|
||||||
|
FirstName = r.FirstName,
|
||||||
|
LastName = r.LastName,
|
||||||
|
PositionName = r.PositionName,
|
||||||
|
ProfileId = r.ProfileId,
|
||||||
|
KeycloakId = r.KeycloakId,
|
||||||
|
ApproveStatus = "PENDING",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// save to database
|
// save to database
|
||||||
|
|
@ -1989,7 +2014,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
// เปลี่ยนมาอ่านจากฐานข้อมูลแทน read_db
|
// เปลี่ยนมาอ่านจากฐานข้อมูลแทน read_db
|
||||||
|
|
||||||
Dear = rawData.Dear ?? "",
|
Dear = rawData.Dear ?? "",
|
||||||
CommanderPosition = rawData.CommanderPosition ?? "",
|
CommanderPosition = rawData.CommanderPosition ?? "",
|
||||||
PositionName = rawData.PositionName ?? "",
|
PositionName = rawData.PositionName ?? "",
|
||||||
PositionLevelName = rawData.PositionLevelName ?? "",
|
PositionLevelName = rawData.PositionLevelName ?? "",
|
||||||
OrganizationName = orgName,
|
OrganizationName = orgName,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
using System.ComponentModel.DataAnnotations;
|
using BMA.EHR.Domain.Models.Base;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
|
namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
|
||||||
{
|
{
|
||||||
|
|
@ -99,6 +101,30 @@ namespace BMA.EHR.Leave.Service.DTOs.LeaveRequest
|
||||||
|
|
||||||
public string? CoupleDaySumTotalHistory { get; set; }
|
public string? CoupleDaySumTotalHistory { get; set; }
|
||||||
|
|
||||||
|
public string? Approvers { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class LeaveRequestApproverDto
|
||||||
|
{
|
||||||
|
[JsonProperty("seq")]
|
||||||
|
public int Seq { get; set; } = 0;
|
||||||
|
|
||||||
|
[JsonProperty("prefix")]
|
||||||
|
public string Prefix { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[JsonProperty("firstName")]
|
||||||
|
public string FirstName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[JsonProperty("lastName")]
|
||||||
|
public string LastName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[JsonProperty("positionName")]
|
||||||
|
public string PositionName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[JsonProperty("profileId")]
|
||||||
|
public Guid ProfileId { get; set; } = Guid.Empty;
|
||||||
|
|
||||||
|
[JsonProperty("keycloakId")]
|
||||||
|
public Guid KeycloakId { get; set; } = Guid.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue