แก้ไขข้อมมูลบุคคลบรรจุ

This commit is contained in:
Kittapath 2023-07-05 16:22:44 +07:00
parent 0c56512f54
commit 258a95a0e2
19 changed files with 11975 additions and 231 deletions

View file

@ -96,8 +96,8 @@ namespace BMA.EHR.Placement.Service.Controllers
FullName = x.Prefix == null ? null : x.Prefix.Name + $"{x.Firstname} {x.Lastname}",
IdCard = x.CitizenId,
ProfilePhoto = x.Id,
OrganizationName = x.OrganizationPosition == null ? null : x.OrganizationPosition.OrganizationId,////
OrganizationShortName = x.OrganizationPosition == null ? null : x.OrganizationPosition.OrganizationId,////
OrganizationName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationOrganization == null ? null : x.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
OrganizationShortName = x.OrganizationPosition == null ? null : (x.OrganizationPosition.Organization == null ? null : (x.OrganizationPosition.Organization.OrganizationShortName == null ? null : x.OrganizationPosition.Organization.OrganizationShortName.Name)),////
PositionNumber = x.PositionNumber == null ? null : x.PositionNumber.Name,
PositionPath = x.PositionPath == null ? null : x.PositionPath.Name,
ReportingDate = x.ReportingDate,
@ -287,51 +287,285 @@ namespace BMA.EHR.Placement.Service.Controllers
if (save_posNo == null)
return Error(GlobalMessages.PositionPosNoNotFound, 404);
person.PositionNumber = save_posNo;
var save_orgPosition = await _context.OrganizationPositions.FirstOrDefaultAsync(x => x.PositionNumber == save_posNo);
if (save_orgPosition == null)
return Error(GlobalMessages.PositionPosNoNotFound, 404);
person.OrganizationPosition = save_orgPosition;
}
if (req.PositionId != null)
{
var save_position = await _context.PositionPaths.FindAsync(req.PositionId);
if (save_position == null)
var save = await _context.PositionPaths.FindAsync(req.PositionId);
if (save == null)
return Error(GlobalMessages.PositionPathNotFound, 404);
person.PositionPath = save_position;
person.PositionPath = save;
}
if (req.PositionLevelId != null)
{
var save_positionLevel = await _context.PositionLevels.FindAsync(req.PositionLevelId);
if (save_positionLevel == null)
var save = await _context.PositionLevels.FindAsync(req.PositionLevelId);
if (save == null)
return Error(GlobalMessages.PositionLevelNotFound, 404);
person.PositionLevel = save_positionLevel;
person.PositionLevel = save;
}
if (req.PositionLineId != null)
{
var save_positionLine = await _context.PositionLines.FindAsync(req.PositionLineId);
if (save_positionLine == null)
var save = await _context.PositionLines.FindAsync(req.PositionLineId);
if (save == null)
return Error(GlobalMessages.PositionLineNotFound, 404);
person.PositionLine = save_positionLine;
person.PositionLine = save;
}
if (req.PositionPathSideId != null)
{
var save_positionPathSide = await _context.PositionPathSides.FindAsync(req.PositionPathSideId);
if (save_positionPathSide == null)
var save = await _context.PositionPathSides.FindAsync(req.PositionPathSideId);
if (save == null)
return Error(GlobalMessages.PositionPathSideNotFound, 404);
person.PositionPathSide = save_positionPathSide;
person.PositionPathSide = save;
}
if (req.PositionTypeId != null)
{
var save_positionType = await _context.PositionTypes.FindAsync(req.PositionTypeId);
if (save_positionType == null)
var save = await _context.PositionTypes.FindAsync(req.PositionTypeId);
if (save == null)
return Error(GlobalMessages.PositionTypeNotFound, 404);
person.PositionType = save_positionType;
person.PositionType = save;
}
person.Amount = req.SalaryAmount;
person.MouthSalaryAmount = req.MouthSalaryAmount;
person.PositionSalaryAmount = req.PositionSalaryAmount;
person.RecruitDate = req.ContainDate;
person.LastUpdateFullName = FullName ?? "System Administrator";
person.LastUpdateUserId = UserId ?? "";
person.LastUpdatedAt = DateTime.Now;
_context.SaveChanges();
return Success();
}
[HttpGet("information/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateInformation([FromBody] PersonInformationRequest req, Guid personalId)
{
var person = await _context.PlacementProfiles.FindAsync(personalId);
if (person == null)
return Error(GlobalMessages.DataNotFound, 404);
if (req.PrefixId != null)
{
var save = await _context.Prefixes
.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == req.PrefixId);
if (save == null)
return Error(GlobalMessages.PrefixNotFound, 404);
person.Prefix = save;
}
if (req.GenderId != null)
{
var save = await _context.Genders
.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == req.GenderId);
if (save == null)
return Error(GlobalMessages.GenderNotFound, 404);
person.Gender = save;
}
if (req.RelationshipId != null)
{
var save = await _context.Relationships
.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == req.RelationshipId);
if (save == null)
return Error(GlobalMessages.RelationshipNotFound, 404);
person.Relationship = save;
}
if (req.BloodGroupId != null)
{
var save = await _context.BloodGroups
.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == req.BloodGroupId);
if (save == null)
return Error(GlobalMessages.BloodGroupNotFound, 404);
person.BloodGroup = save;
}
if (req.ReligionId != null)
{
var save = await _context.Religions
.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == req.ReligionId);
if (save == null)
return Error(GlobalMessages.ReligionNotFound, 404);
person.Religion = save;
}
person.CitizenId = req.CitizenId;
person.Firstname = req.FirstName;
person.Lastname = req.LastName;
person.Nationality = req.Nationality;
person.Race = req.Race;
person.DateOfBirth = req.BirthDate;
person.Telephone = req.TelephoneNumber;
person.LastUpdateFullName = FullName ?? "System Administrator";
person.LastUpdateUserId = UserId ?? "";
person.LastUpdatedAt = DateTime.Now;
_context.SaveChanges();
return Success();
}
[HttpGet("address/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateAddress([FromBody] PersonAddressRequest req, Guid personalId)
{
var person = await _context.PlacementProfiles.FindAsync(personalId);
if (person == null)
return Error(GlobalMessages.DataNotFound, 404);
if (req.RegistrationSubDistrictId != null)
{
var save = await _context.SubDistricts.FindAsync(req.RegistrationSubDistrictId);
if (save == null)
return Error(GlobalMessages.SubDistrictNotFound, 404);
person.RegistSubDistrict = save;
person.RegistZipCode = save.ZipCode;
}
if (req.RegistrationDistrictId != null)
{
var save = await _context.Districts.FindAsync(req.RegistrationDistrictId);
if (save == null)
return Error(GlobalMessages.DistrictNotFound, 404);
person.RegistDistrict = save;
}
if (req.RegistrationProvinceId != null)
{
var save = await _context.Provinces.FindAsync(req.RegistrationProvinceId);
if (save == null)
return Error(GlobalMessages.ProvinceNotFound, 404);
person.RegistProvince = save;
}
if (req.CurrentSubDistrictId != null)
{
var save = await _context.SubDistricts.FindAsync(req.CurrentSubDistrictId);
if (save == null)
return Error(GlobalMessages.SubDistrictNotFound, 404);
person.CurrentSubDistrict = save;
person.CurrentZipCode = save.ZipCode;
}
if (req.CurrentDistrictId != null)
{
var save = await _context.Districts.FindAsync(req.CurrentDistrictId);
if (save == null)
return Error(GlobalMessages.DistrictNotFound, 404);
person.CurrentDistrict = save;
}
if (req.CurrentProvinceId != null)
{
var save = await _context.Provinces.FindAsync(req.CurrentProvinceId);
if (save == null)
return Error(GlobalMessages.ProvinceNotFound, 404);
person.CurrentProvince = save;
}
person.RegistSame = req.RegistrationSame;
person.LastUpdateFullName = FullName ?? "System Administrator";
person.LastUpdateUserId = UserId ?? "";
person.LastUpdatedAt = DateTime.Now;
_context.SaveChanges();
return Success();
}
[HttpGet("family/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateFamily([FromBody] PersonFamilyRequest req, Guid personalId)
{
var person = await _context.PlacementProfiles.FindAsync(personalId);
if (person == null)
return Error(GlobalMessages.DataNotFound, 404);
if (req.Couple == true && req.CouplePrefixId != null)
{
var save_prefix = await _context.Prefixes
.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == req.CouplePrefixId);
if (save_prefix == null)
return Error(GlobalMessages.PrefixNotFound, 404);
person.MarryPrefix = save_prefix;
}
if (req.FatherPrefixId != null)
{
var save_prefix = await _context.Prefixes
.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == req.FatherPrefixId);
if (save_prefix == null)
return Error(GlobalMessages.PrefixNotFound, 404);
person.FatherPrefix = save_prefix;
}
if (req.MotherPrefixId != null)
{
var save_prefix = await _context.Prefixes
.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == req.MotherPrefixId);
if (save_prefix == null)
return Error(GlobalMessages.PrefixNotFound, 404);
person.MotherPrefix = save_prefix;
}
person.Marry = req.Couple;
person.MarryFirstName = req.CoupleFirstName;
person.MarryLastName = req.CoupleLastName;
// person.MarryLastNameOld = req.CoupleLastNameOld;
person.MarryOccupation = req.CoupleCareer;
// person.MarryCitizenId = req.CoupleCitizenId;
// person.MarryLive = req.CoupleLive;
person.FatherFirstName = req.FatherFirstName;
person.FatherLastName = req.FatherLastName;
person.FatherOccupation = req.FatherCareer;
// person.FatherCitizenId = req.FatherCitizenId;
// person.FatherLive = req.FatherLive;
person.MotherFirstName = req.MotherFirstName;
person.MotherLastName = req.MotherLastName;
person.MotherOccupation = req.MotherCareer;
// person.MotherCitizenId = req.MotherCitizenId;
// person.MotherLive = req.MotherLive;
person.LastUpdateFullName = FullName ?? "System Administrator";
person.LastUpdateUserId = UserId ?? "";
person.LastUpdatedAt = DateTime.Now;
_context.SaveChanges();
return Success();
}
[HttpGet("certificate/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateCertificate([FromBody] PersonCertificateRequest req, Guid personalId)
{
var person = await _context.PlacementProfiles.FindAsync(personalId);
if (person == null)
return Error(GlobalMessages.DataNotFound, 404);
person.LastUpdateFullName = FullName ?? "System Administrator";
person.LastUpdateUserId = UserId ?? "";
person.LastUpdatedAt = DateTime.Now;
_context.SaveChanges();
return Success();
}
[HttpGet("education/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateEducation([FromBody] PersonEducationRequest req, Guid personalId)
{
var person = await _context.PlacementProfiles.FindAsync(personalId);
if (person == null)
return Error(GlobalMessages.DataNotFound, 404);
person.LastUpdateFullName = FullName ?? "System Administrator";
person.LastUpdateUserId = UserId ?? "";
person.LastUpdatedAt = DateTime.Now;
_context.SaveChanges();
return Success();