แก้ระบบบรรจุผูกโครงสร้างใหม่
This commit is contained in:
parent
57164f5d45
commit
18d75f4b04
37 changed files with 79295 additions and 3904 deletions
|
|
@ -8,7 +8,9 @@ using BMA.EHR.Placement.Service.Requests;
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Newtonsoft.Json;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Controllers
|
||||
|
|
@ -26,18 +28,21 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
private readonly ApplicationDBContext _context;
|
||||
private readonly MinIOService _documentService;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public PlacementReceiveController(PlacementRepository repository,
|
||||
NotificationRepository repositoryNoti,
|
||||
ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
_repository = repository;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
|
@ -45,6 +50,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||
|
||||
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
|
||||
|
||||
|
|
@ -61,51 +67,84 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
[HttpGet()]
|
||||
public async Task<ActionResult<ResponseObject>> GetListByAdmin()
|
||||
{
|
||||
var rootId = "";
|
||||
var child1Id = "";
|
||||
var child2Id = "";
|
||||
var child3Id = "";
|
||||
var child4Id = "";
|
||||
var apiUrl = $"{_configuration["API"]}org/profile/keycloak/position";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
|
||||
var placementReceives = await _context.PlacementReceives.AsQueryable()
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
p.CitizenId,
|
||||
Prefix = p.Prefix.Name,
|
||||
p.Firstname,
|
||||
p.Lastname,
|
||||
p.DateOfBirth,
|
||||
Gender = p.Gender == null ? null : p.Gender.Name,
|
||||
p.Status,
|
||||
p.Amount,
|
||||
p.RecruitDate,
|
||||
PositionNumber = p.PositionNumber == null ? null : p.PositionNumber.Name,
|
||||
PositionPath = p.PositionPath == null ? null : p.PositionPath.Name,
|
||||
PositionPathSide = p.PositionPathSide == null ? null : p.PositionPathSide.Name,
|
||||
PositionType = p.PositionType == null ? null : p.PositionType.Name,
|
||||
PositionLine = p.PositionLine == null ? null : p.PositionLine.Name,
|
||||
PositionLevel = p.PositionLevel == null ? null : p.PositionLevel.Name,
|
||||
PosNoId = p.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumber.Id,
|
||||
PositionId = p.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPath.Id,
|
||||
PositionPathSideId = p.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPathSide.Id,
|
||||
PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id,
|
||||
PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
|
||||
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
|
||||
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
|
||||
OrganizationName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationOrganization == null ? null : p.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
|
||||
OrganizationShortName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationShortName == null ? null : p.OrganizationPosition.Organization.OrganizationShortName.Name)),////
|
||||
p.IsActive,
|
||||
p.Reason,
|
||||
p.EducationOld,
|
||||
p.AmountOld,
|
||||
p.PositionTypeOld,
|
||||
p.PositionLevelOld,
|
||||
p.PositionNumberOld,
|
||||
p.OrganizationPositionOld,
|
||||
p.CreatedAt,
|
||||
})
|
||||
.ToListAsync();
|
||||
if (PlacementAdmin == true)
|
||||
placementReceives.Where(x => x.Status.Trim().ToUpper().Contains("PENDING"));
|
||||
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
||||
|
||||
return Success(placementReceives);
|
||||
if (org == null || org.result == null)
|
||||
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
|
||||
rootId = org.result.rootId == null ? "" : org.result.rootId;
|
||||
child1Id = org.result.child1Id == null ? "" : org.result.child1Id;
|
||||
child2Id = org.result.child2Id == null ? "" : org.result.child2Id;
|
||||
child3Id = org.result.child3Id == null ? "" : org.result.child3Id;
|
||||
child4Id = org.result.child4Id == null ? "" : org.result.child4Id;
|
||||
|
||||
var placementReceives = await _context.PlacementReceives.AsQueryable()
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Where(x => PlacementAdmin == true ? true : (rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))))
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
p.citizenId,
|
||||
p.prefix,
|
||||
p.firstName,
|
||||
p.lastName,
|
||||
p.DateOfBirth,
|
||||
Gender = p.Gender == null ? null : p.Gender.Name,
|
||||
p.Status,
|
||||
p.Amount,
|
||||
p.RecruitDate,
|
||||
p.root,
|
||||
p.rootId,
|
||||
p.rootShortName,
|
||||
p.child1,
|
||||
p.child1Id,
|
||||
p.child1ShortName,
|
||||
p.child2,
|
||||
p.child2Id,
|
||||
p.child2ShortName,
|
||||
p.child3,
|
||||
p.child3Id,
|
||||
p.child3ShortName,
|
||||
p.child4,
|
||||
p.child4Id,
|
||||
p.child4ShortName,
|
||||
p.orgRevisionId,
|
||||
p.positionId,
|
||||
p.posMasterNo,
|
||||
p.positionName,
|
||||
p.positionField,
|
||||
p.posTypeId,
|
||||
p.posTypeName,
|
||||
p.posLevelId,
|
||||
p.posLevelName,
|
||||
p.IsActive,
|
||||
p.Reason,
|
||||
p.EducationOld,
|
||||
p.AmountOld,
|
||||
p.PositionTypeOld,
|
||||
p.PositionLevelOld,
|
||||
p.PositionNumberOld,
|
||||
p.OrganizationPositionOld,
|
||||
p.CreatedAt,
|
||||
})
|
||||
.ToListAsync();
|
||||
// if (PlacementAdmin == true)
|
||||
// placementReceives.Where(x => x.Status.Trim().ToUpper().Contains("PENDING"));
|
||||
|
||||
return Success(placementReceives);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -126,11 +165,10 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
{
|
||||
p.Id,
|
||||
// ProfileId = p.Profile.Id,
|
||||
p.CitizenId,
|
||||
Prefix = p.Prefix.Name,
|
||||
PrefixId = p.Prefix.Id,
|
||||
p.Firstname,
|
||||
p.Lastname,
|
||||
p.citizenId,
|
||||
p.prefix,
|
||||
p.firstName,
|
||||
p.lastName,
|
||||
p.DateOfBirth,
|
||||
Gender = p.Gender == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Gender.Id,
|
||||
p.Nationality,
|
||||
|
|
@ -142,13 +180,30 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
p.Status,
|
||||
p.Amount,
|
||||
p.RecruitDate,
|
||||
PosNoId = p.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumber.Id,
|
||||
PositionId = p.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPath.Id,
|
||||
PositionPathSideId = p.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPathSide.Id,
|
||||
PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id,
|
||||
PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
|
||||
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
|
||||
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
|
||||
p.root,
|
||||
p.rootId,
|
||||
p.rootShortName,
|
||||
p.child1,
|
||||
p.child1Id,
|
||||
p.child1ShortName,
|
||||
p.child2,
|
||||
p.child2Id,
|
||||
p.child2ShortName,
|
||||
p.child3,
|
||||
p.child3Id,
|
||||
p.child3ShortName,
|
||||
p.child4,
|
||||
p.child4Id,
|
||||
p.child4ShortName,
|
||||
p.orgRevisionId,
|
||||
p.positionId,
|
||||
p.posMasterNo,
|
||||
p.positionName,
|
||||
p.positionField,
|
||||
p.posTypeId,
|
||||
p.posTypeName,
|
||||
p.posLevelId,
|
||||
p.posLevelName,
|
||||
p.CreatedAt,
|
||||
p.Reason,
|
||||
p.EducationOld,
|
||||
|
|
@ -157,7 +212,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
p.PositionLevelOld,
|
||||
p.PositionNumberOld,
|
||||
p.OrganizationPositionOld,
|
||||
Avatar = p.Avatar == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Avatar.Id,
|
||||
// Avatar = p.Avatar == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Avatar.Id,
|
||||
PlacementReceiveDocs = p.PlacementReceiveDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||
})
|
||||
.FirstOrDefaultAsync();
|
||||
|
|
@ -178,11 +233,10 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
{
|
||||
data.Id,
|
||||
// data.ProfileId,
|
||||
data.CitizenId,
|
||||
data.Prefix,
|
||||
data.PrefixId,
|
||||
data.Firstname,
|
||||
data.Lastname,
|
||||
data.citizenId,
|
||||
data.prefix,
|
||||
data.firstName,
|
||||
data.lastName,
|
||||
data.DateOfBirth,
|
||||
data.Gender,
|
||||
data.Nationality,
|
||||
|
|
@ -194,13 +248,30 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
data.Status,
|
||||
data.Amount,
|
||||
data.RecruitDate,
|
||||
data.PosNoId,
|
||||
data.PositionId,
|
||||
data.PositionPathSideId,
|
||||
data.PositionTypeId,
|
||||
data.PositionLineId,
|
||||
data.PositionLevelId,
|
||||
data.OrganizationPositionId,
|
||||
data.root,
|
||||
data.rootId,
|
||||
data.rootShortName,
|
||||
data.child1,
|
||||
data.child1Id,
|
||||
data.child1ShortName,
|
||||
data.child2,
|
||||
data.child2Id,
|
||||
data.child2ShortName,
|
||||
data.child3,
|
||||
data.child3Id,
|
||||
data.child3ShortName,
|
||||
data.child4,
|
||||
data.child4Id,
|
||||
data.child4ShortName,
|
||||
data.orgRevisionId,
|
||||
data.positionId,
|
||||
data.posMasterNo,
|
||||
data.positionName,
|
||||
data.positionField,
|
||||
data.posTypeId,
|
||||
data.posTypeName,
|
||||
data.posLevelId,
|
||||
data.posLevelName,
|
||||
data.CreatedAt,
|
||||
data.Reason,
|
||||
data.EducationOld,
|
||||
|
|
@ -209,7 +280,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
data.PositionLevelOld,
|
||||
data.PositionNumberOld,
|
||||
data.OrganizationPositionOld,
|
||||
Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
|
||||
// Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
|
||||
Docs = placementReceiveDocs,
|
||||
};
|
||||
|
||||
|
|
@ -227,17 +298,13 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
[HttpPost()]
|
||||
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementReceiveRequest req)
|
||||
{
|
||||
var prefix = await _context.Prefixes.FindAsync(req.Prefix);
|
||||
if (prefix == null)
|
||||
return Error(GlobalMessages.PrefixNotFound, 404);
|
||||
|
||||
var placementReceive = new PlacementReceive
|
||||
{
|
||||
// Profile = profile,
|
||||
CitizenId = req.CitizenId,
|
||||
Prefix = prefix,
|
||||
Firstname = req.Firstname,
|
||||
Lastname = req.Lastname,
|
||||
citizenId = req.citizenId,
|
||||
prefix = req.prefix,
|
||||
firstName = req.firstName,
|
||||
lastName = req.lastName,
|
||||
DateOfBirth = req.BirthDate,
|
||||
Gender = await _context.Genders.FindAsync(req.GenderId),
|
||||
Nationality = req.Nationality,
|
||||
|
|
@ -254,30 +321,28 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
var profile = await _context.Profiles
|
||||
.Include(x => x.PositionLevel)
|
||||
.Include(x => x.PositionType)
|
||||
.Include(x => x.PosNo)
|
||||
.Include(x => x.Salaries)
|
||||
.Include(x => x.Educations)
|
||||
.Include(x => x.Position)
|
||||
.FirstOrDefaultAsync(x => x.CitizenId == req.CitizenId);
|
||||
if (profile != null)
|
||||
{
|
||||
placementReceive.EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}";
|
||||
placementReceive.AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount;
|
||||
placementReceive.PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name;
|
||||
placementReceive.PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name;
|
||||
placementReceive.PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name;
|
||||
placementReceive.OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}";
|
||||
}
|
||||
// var profile = await _context.Profiles
|
||||
// .Include(x => x.PositionLevel)
|
||||
// .Include(x => x.PositionType)
|
||||
// .Include(x => x.PosNo)
|
||||
// .Include(x => x.Salaries)
|
||||
// .Include(x => x.Educations)
|
||||
// .Include(x => x.Position)
|
||||
// .FirstOrDefaultAsync(x => x.CitizenId == req.CitizenId);
|
||||
// if (profile != null)
|
||||
// {
|
||||
// placementReceive.EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}";
|
||||
// placementReceive.AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount;
|
||||
// placementReceive.PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name;
|
||||
// placementReceive.PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name;
|
||||
// placementReceive.PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name;
|
||||
// placementReceive.OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}";
|
||||
// }
|
||||
|
||||
await _context.PlacementReceives.AddAsync(placementReceive);
|
||||
await _context.SaveChangesAsync();
|
||||
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
||||
{
|
||||
// foreach (var file in Request.Form.Files)
|
||||
// {
|
||||
var file = Request.Form.Files[0];
|
||||
var fileExtension = Path.GetExtension(file.FileName);
|
||||
|
||||
|
|
@ -286,21 +351,8 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
.FirstOrDefaultAsync(x => x.Id == doc.Id);
|
||||
if (_doc != null)
|
||||
{
|
||||
// var placementReceiveDoc = new PlacementReceiveDoc
|
||||
// {
|
||||
// PlacementReceive = placementReceive,
|
||||
// Document = _doc,
|
||||
// CreatedFullName = FullName ?? "System Administrator",
|
||||
// CreatedUserId = UserId ?? "",
|
||||
// CreatedAt = DateTime.Now,
|
||||
// LastUpdateFullName = FullName ?? "System Administrator",
|
||||
// LastUpdateUserId = UserId ?? "",
|
||||
// LastUpdatedAt = DateTime.Now,
|
||||
// };
|
||||
// await _context.PlacementReceiveDocs.AddAsync(placementReceiveDoc);
|
||||
placementReceive.Avatar = _doc;
|
||||
}
|
||||
// }
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
|
|
@ -385,59 +437,54 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
if (uppdated == null)
|
||||
return Error(GlobalMessages.PlacementReceiveNotFound, 404);
|
||||
if (req.PosNoId != null)
|
||||
{
|
||||
var save_posNo = await _context.PositionNumbers.FindAsync(req.PosNoId);
|
||||
if (save_posNo == null)
|
||||
return Error(GlobalMessages.PositionPosNoNotFound, 404);
|
||||
uppdated.PositionNumber = save_posNo;
|
||||
|
||||
var save_orgPosition = await _context.OrganizationPositions.FirstOrDefaultAsync(x => x.PositionNumber == save_posNo);
|
||||
if (save_orgPosition == null)
|
||||
return Error(GlobalMessages.PositionPosNoNotFound, 404);
|
||||
uppdated.OrganizationPosition = save_orgPosition;
|
||||
}
|
||||
|
||||
if (req.PositionId != null)
|
||||
{
|
||||
var save = await _context.PositionPaths.FindAsync(req.PositionId);
|
||||
if (save == null)
|
||||
return Error(GlobalMessages.PositionPathNotFound, 404);
|
||||
uppdated.PositionPath = save;
|
||||
}
|
||||
|
||||
if (req.PositionLevelId != null)
|
||||
{
|
||||
var save = await _context.PositionLevels.FindAsync(req.PositionLevelId);
|
||||
if (save == null)
|
||||
return Error(GlobalMessages.PositionLevelNotFound, 404);
|
||||
uppdated.PositionLevel = save;
|
||||
}
|
||||
|
||||
if (req.PositionLineId != null)
|
||||
{
|
||||
var save = await _context.PositionLines.FindAsync(req.PositionLineId);
|
||||
if (save == null)
|
||||
return Error(GlobalMessages.PositionLineNotFound, 404);
|
||||
uppdated.PositionLine = save;
|
||||
}
|
||||
|
||||
if (req.PositionPathSideId != null)
|
||||
{
|
||||
var save = await _context.PositionPathSides.FindAsync(req.PositionPathSideId);
|
||||
if (save == null)
|
||||
return Error(GlobalMessages.PositionPathSideNotFound, 404);
|
||||
uppdated.PositionPathSide = save;
|
||||
}
|
||||
|
||||
if (req.PositionTypeId != null)
|
||||
{
|
||||
var save = await _context.PositionTypes.FindAsync(req.PositionTypeId);
|
||||
if (save == null)
|
||||
return Error(GlobalMessages.PositionTypeNotFound, 404);
|
||||
uppdated.PositionType = save;
|
||||
var apiUrl = $"{_configuration["API"]}org/find/all";
|
||||
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
|
||||
var _res = await client.PostAsJsonAsync(apiUrl, new
|
||||
{
|
||||
node = req.node,
|
||||
nodeId = req.nodeId,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
||||
|
||||
if (org == null || org.result == null)
|
||||
return Error("ไม่พบหน่วยงานนี้ในระบบ", 404);
|
||||
|
||||
uppdated.root = org.result.root;
|
||||
uppdated.rootId = org.result.rootId;
|
||||
uppdated.rootShortName = org.result.rootShortName;
|
||||
uppdated.child1 = req.node <= 0 ? null : org.result.child1;
|
||||
uppdated.child1Id = req.node <= 0 ? null : org.result.child1Id;
|
||||
uppdated.child1ShortName = req.node <= 0 ? null : org.result.child1ShortName;
|
||||
uppdated.child2 = req.node <= 1 ? null : org.result.child2;
|
||||
uppdated.child2Id = req.node <= 1 ? null : org.result.child2Id;
|
||||
uppdated.child2ShortName = req.node <= 1 ? null : org.result.child2ShortName;
|
||||
uppdated.child3 = req.node <= 2 ? null : org.result.child3;
|
||||
uppdated.child3Id = req.node <= 2 ? null : org.result.child3Id;
|
||||
uppdated.child3ShortName = req.node <= 2 ? null : org.result.child3ShortName;
|
||||
uppdated.child4 = req.node <= 3 ? null : org.result.child4;
|
||||
uppdated.child4Id = req.node <= 3 ? null : org.result.child4Id;
|
||||
uppdated.child4ShortName = req.node <= 3 ? null : org.result.child4ShortName;
|
||||
}
|
||||
|
||||
uppdated.posmasterId = req.posmasterId;
|
||||
uppdated.node = req.node;
|
||||
uppdated.nodeId = req.nodeId;
|
||||
uppdated.orgRevisionId = req.orgRevisionId;
|
||||
uppdated.positionId = req.positionId;
|
||||
uppdated.posMasterNo = req.posMasterNo;
|
||||
uppdated.positionName = req.positionName;
|
||||
uppdated.positionField = req.positionField;
|
||||
uppdated.posTypeId = req.posTypeId;
|
||||
uppdated.posTypeName = req.posTypeName;
|
||||
uppdated.posLevelId = req.posLevelId;
|
||||
uppdated.posLevelName = req.posLevelName;
|
||||
uppdated.Amount = req.Amount;
|
||||
uppdated.RecruitDate = req.RecruitDate;
|
||||
uppdated.Status = "PENDING";
|
||||
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
|
|
@ -464,14 +511,6 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
if (uppdated == null)
|
||||
return Error(GlobalMessages.PlacementReceiveNotFound, 404);
|
||||
|
||||
if (req.PrefixId != null)
|
||||
{
|
||||
var save = await _context.Prefixes.FindAsync(req.PrefixId);
|
||||
if (save == null)
|
||||
return Error(GlobalMessages.PrefixNotFound, 404);
|
||||
uppdated.Prefix = save;
|
||||
}
|
||||
|
||||
if (req.RelationshipId != null)
|
||||
{
|
||||
var save = await _context.Relationships.FindAsync(req.RelationshipId);
|
||||
|
|
@ -503,9 +542,10 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
return Error(GlobalMessages.GenderNotFound, 404);
|
||||
uppdated.Gender = save;
|
||||
}
|
||||
uppdated.CitizenId = req.CitizenId;
|
||||
uppdated.Firstname = req.Firstname;
|
||||
uppdated.Lastname = req.Lastname;
|
||||
uppdated.citizenId = req.citizenId;
|
||||
uppdated.prefix = req.prefix;
|
||||
uppdated.firstName = req.firstName;
|
||||
uppdated.lastName = req.lastName;
|
||||
uppdated.DateOfBirth = req.DateOfBirth;
|
||||
uppdated.Nationality = req.Nationality;
|
||||
uppdated.Race = req.Race;
|
||||
|
|
@ -591,23 +631,23 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// หน่วยงานที่ถูกเลือกไปแล้ว
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("use")]
|
||||
public async Task<ActionResult<ResponseObject>> GetReceiveUse()
|
||||
{
|
||||
var receives = await _context.PlacementReceives
|
||||
.Where(x => x.PositionNumber != null)
|
||||
.Select(x => x.PositionNumber.Id)
|
||||
.ToListAsync();
|
||||
// /// <summary>
|
||||
// /// หน่วยงานที่ถูกเลือกไปแล้ว
|
||||
// /// </summary>
|
||||
// /// <returns></returns>
|
||||
// /// <response code="200"></response>
|
||||
// /// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
// /// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
// /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
// [HttpGet("use")]
|
||||
// public async Task<ActionResult<ResponseObject>> GetReceiveUse()
|
||||
// {
|
||||
// var receives = await _context.PlacementReceives
|
||||
// .Where(x => x.PositionNumber != null)
|
||||
// .Select(x => x.PositionNumber.Id)
|
||||
// .ToListAsync();
|
||||
|
||||
return Success(receives);
|
||||
}
|
||||
// return Success(receives);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue