บันทึกข้อมูลรับโอน
This commit is contained in:
parent
19803fd523
commit
dec96d2bd3
8 changed files with 16467 additions and 60 deletions
|
|
@ -125,7 +125,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
ProfileId = p.Profile.Id,
|
||||
// ProfileId = p.Profile.Id,
|
||||
p.CitizenId,
|
||||
Prefix = p.Prefix.Name,
|
||||
PrefixId = p.Prefix.Id,
|
||||
|
|
@ -177,7 +177,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
var _data = new
|
||||
{
|
||||
data.Id,
|
||||
data.ProfileId,
|
||||
// data.ProfileId,
|
||||
data.CitizenId,
|
||||
data.Prefix,
|
||||
data.PrefixId,
|
||||
|
|
@ -227,42 +227,25 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
[HttpPost()]
|
||||
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementReceiveRequest req)
|
||||
{
|
||||
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.KeycloakId == Guid.Parse(UserId));
|
||||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
var prefix = await _context.Prefixes.FindAsync(req.Prefix);
|
||||
if (prefix == null)
|
||||
return Error(GlobalMessages.PrefixNotFound, 404);
|
||||
|
||||
var placementReceive = new PlacementReceive
|
||||
{
|
||||
Profile = profile,
|
||||
// Profile = profile,
|
||||
CitizenId = req.CitizenId,
|
||||
Prefix = prefix,
|
||||
Firstname = req.Firstname,
|
||||
Lastname = req.Lastname,
|
||||
DateOfBirth = req.DateOfBirth,
|
||||
Gender = await _context.Genders.FindAsync(req.Gender),
|
||||
DateOfBirth = req.BirthDate,
|
||||
Gender = await _context.Genders.FindAsync(req.GenderId),
|
||||
Nationality = req.Nationality,
|
||||
Race = req.Race,
|
||||
Religion = await _context.Religions.FindAsync(req.Religion),
|
||||
BloodGroup = await _context.BloodGroups.FindAsync(req.BloodGroup),
|
||||
Relationship = await _context.Relationships.FindAsync(req.Relationship),
|
||||
Religion = await _context.Religions.FindAsync(req.ReligionId),
|
||||
BloodGroup = await _context.BloodGroups.FindAsync(req.BloodGroupId),
|
||||
Relationship = await _context.Relationships.FindAsync(req.RelationshipId),
|
||||
TelephoneNumber = req.TelephoneNumber,
|
||||
EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}",
|
||||
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount,
|
||||
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
|
||||
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
|
||||
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
|
||||
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
|
||||
Status = "WAITTING",
|
||||
CreatedUserId = UserId ?? "System Administrator",
|
||||
CreatedFullName = FullName ?? "",
|
||||
|
|
@ -271,6 +254,24 @@ 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().PositionSalaryAmount;
|
||||
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)
|
||||
|
|
@ -463,7 +464,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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue