แก้apiประวัติศิกษาบรรจุ
This commit is contained in:
parent
dcc1dd9666
commit
8c50baaf5f
1 changed files with 106 additions and 88 deletions
|
|
@ -793,6 +793,36 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
[HttpPost("certificate/{personalId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> CreateCertificate([FromBody] PersonCertificateRequest req, Guid personalId)
|
||||
{
|
||||
var person = await _context.PlacementProfiles
|
||||
.Include(x => x.PlacementCertificates)
|
||||
.FirstOrDefaultAsync(x => x.Id == personalId);
|
||||
if (person == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
var data = new PlacementCertificate
|
||||
{
|
||||
PlacementProfile = person,
|
||||
CertificateNo = req.CertificateNo,
|
||||
Issuer = req.Issuer,
|
||||
IssueDate = req.IssueDate,
|
||||
ExpireDate = req.ExpireDate,
|
||||
CertificateType = req.CertificateType,
|
||||
CreatedUserId = FullName ?? "",
|
||||
CreatedFullName = UserId ?? "System Administrator",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
await _context.PlacementCertificates.AddAsync(data);
|
||||
_context.SaveChanges();
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
[HttpPut("certificate/{personalId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdateCertificate([FromBody] PersonCertificateRequest req, Guid personalId)
|
||||
{
|
||||
|
|
@ -802,39 +832,17 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
if (person == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
if (req.Id == null)
|
||||
{
|
||||
var data = new PlacementCertificate
|
||||
{
|
||||
PlacementProfile = person,
|
||||
CertificateNo = req.CertificateNo,
|
||||
Issuer = req.Issuer,
|
||||
IssueDate = req.IssueDate,
|
||||
ExpireDate = req.ExpireDate,
|
||||
CertificateType = req.CertificateType,
|
||||
CreatedUserId = FullName ?? "",
|
||||
CreatedFullName = UserId ?? "System Administrator",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
await _context.PlacementCertificates.AddAsync(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
var certificate = person.PlacementCertificates.FirstOrDefault(x => x.Id == req.Id);
|
||||
if (certificate == null)
|
||||
return Error(GlobalMessages.CertificateNotFound, 404);
|
||||
certificate.CertificateNo = req.CertificateNo;
|
||||
certificate.Issuer = req.Issuer;
|
||||
certificate.IssueDate = req.IssueDate;
|
||||
certificate.ExpireDate = req.ExpireDate;
|
||||
certificate.CertificateType = req.CertificateType;
|
||||
certificate.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
certificate.LastUpdateUserId = UserId ?? "";
|
||||
certificate.LastUpdatedAt = DateTime.Now;
|
||||
}
|
||||
var certificate = person.PlacementCertificates.FirstOrDefault(x => x.Id == req.Id);
|
||||
if (certificate == null)
|
||||
return Error(GlobalMessages.CertificateNotFound, 404);
|
||||
certificate.CertificateNo = req.CertificateNo;
|
||||
certificate.Issuer = req.Issuer;
|
||||
certificate.IssueDate = req.IssueDate;
|
||||
certificate.ExpireDate = req.ExpireDate;
|
||||
certificate.CertificateType = req.CertificateType;
|
||||
certificate.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
certificate.LastUpdateUserId = UserId ?? "";
|
||||
certificate.LastUpdatedAt = DateTime.Now;
|
||||
_context.SaveChanges();
|
||||
|
||||
return Success();
|
||||
|
|
@ -857,12 +865,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
[HttpPut("education/{personalId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdateEducation([FromBody] PersonEducationRequest req, Guid personalId)
|
||||
[HttpPost("education/{personalId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> CreateEducation([FromBody] PersonEducationRequest req, Guid personalId)
|
||||
{
|
||||
// var education = await _context.PlacementEducations
|
||||
// .Include(x => x.PlacementProfile)
|
||||
// .FirstOrDefaultAsync(x => x.Id == personalId);
|
||||
var profile = await _context.PlacementProfiles.FirstOrDefaultAsync(x => x.Id == personalId);
|
||||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
|
@ -875,58 +880,71 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
if (positionPath == null && req.PositionPathId != null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
if (req.Id == null)
|
||||
var data = new PlacementEducation
|
||||
{
|
||||
var data = new PlacementEducation
|
||||
{
|
||||
PlacementProfile = profile,
|
||||
EducationLevel = educationLevel,
|
||||
PositionPath = positionPath,
|
||||
Institute = req.Institute,
|
||||
Degree = req.Degree,
|
||||
Field = req.Field,
|
||||
Gpa = req.Gpa,
|
||||
Country = req.Country,
|
||||
Duration = req.Duration,
|
||||
DurationYear = req.DurationYear,
|
||||
Other = req.Other,
|
||||
FundName = req.FundName,
|
||||
FinishDate = req.FinishDate,
|
||||
StartDate = req.StartDate,
|
||||
EndDate = req.EndDate,
|
||||
CreatedUserId = FullName ?? "",
|
||||
CreatedFullName = UserId ?? "System Administrator",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
await _context.PlacementEducations.AddAsync(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
var education = await _context.PlacementEducations.FirstOrDefaultAsync(x => x.Id == req.Id);
|
||||
if (education == null)
|
||||
return Error(GlobalMessages.EducationNotFound, 404);
|
||||
PlacementProfile = profile,
|
||||
EducationLevel = educationLevel,
|
||||
PositionPath = positionPath,
|
||||
Institute = req.Institute,
|
||||
Degree = req.Degree,
|
||||
Field = req.Field,
|
||||
Gpa = req.Gpa,
|
||||
Country = req.Country,
|
||||
Duration = req.Duration,
|
||||
DurationYear = req.DurationYear,
|
||||
Other = req.Other,
|
||||
FundName = req.FundName,
|
||||
FinishDate = req.FinishDate,
|
||||
StartDate = req.StartDate,
|
||||
EndDate = req.EndDate,
|
||||
CreatedUserId = FullName ?? "",
|
||||
CreatedFullName = UserId ?? "System Administrator",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
await _context.PlacementEducations.AddAsync(data);
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
education.EducationLevel = educationLevel;
|
||||
education.PositionPath = positionPath;
|
||||
education.Institute = req.Institute;
|
||||
education.Degree = req.Degree;
|
||||
education.Field = req.Field;
|
||||
education.Gpa = req.Gpa;
|
||||
education.Country = req.Country;
|
||||
education.Duration = req.Duration;
|
||||
education.DurationYear = req.DurationYear;
|
||||
education.Other = req.Other;
|
||||
education.FundName = req.FundName;
|
||||
education.FinishDate = req.FinishDate;
|
||||
education.StartDate = req.StartDate;
|
||||
education.EndDate = req.EndDate;
|
||||
education.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
education.LastUpdateUserId = UserId ?? "";
|
||||
education.LastUpdatedAt = DateTime.Now;
|
||||
}
|
||||
[HttpPut("education/{personalId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdateEducation([FromBody] PersonEducationRequest req, Guid personalId)
|
||||
{
|
||||
var profile = await _context.PlacementProfiles.FirstOrDefaultAsync(x => x.Id == personalId);
|
||||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
var educationLevel = await _context.EducationLevels.FirstOrDefaultAsync(x => x.Id == req.EducationLevelId);
|
||||
if (educationLevel == null && req.EducationLevelId != null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
var positionPath = await _context.PositionPaths.FirstOrDefaultAsync(x => x.Id == req.PositionPathId);
|
||||
if (positionPath == null && req.PositionPathId != null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
var education = await _context.PlacementEducations.FirstOrDefaultAsync(x => x.Id == req.Id);
|
||||
if (education == null)
|
||||
return Error(GlobalMessages.EducationNotFound, 404);
|
||||
|
||||
education.EducationLevel = educationLevel;
|
||||
education.PositionPath = positionPath;
|
||||
education.Institute = req.Institute;
|
||||
education.Degree = req.Degree;
|
||||
education.Field = req.Field;
|
||||
education.Gpa = req.Gpa;
|
||||
education.Country = req.Country;
|
||||
education.Duration = req.Duration;
|
||||
education.DurationYear = req.DurationYear;
|
||||
education.Other = req.Other;
|
||||
education.FundName = req.FundName;
|
||||
education.FinishDate = req.FinishDate;
|
||||
education.StartDate = req.StartDate;
|
||||
education.EndDate = req.EndDate;
|
||||
education.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
education.LastUpdateUserId = UserId ?? "";
|
||||
education.LastUpdatedAt = DateTime.Now;
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue