api ข้อมูลประวัติการศึกษา
This commit is contained in:
parent
85bc0fd359
commit
3d1ff7ee72
2 changed files with 88 additions and 3 deletions
|
|
@ -688,5 +688,74 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
[HttpPut("education/{personalId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdateEducationByPerson([FromBody] PersonEducationRequest req, Guid personalId)
|
||||
{
|
||||
var education = await _context.PlacementEducations
|
||||
.Include(x => x.PlacementProfile)
|
||||
.FirstOrDefaultAsync(x => x.Id == personalId);
|
||||
if (education == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
if (req.Id == null)
|
||||
{
|
||||
var data = new PlacementEducation
|
||||
{
|
||||
PlacementProfile = education.PlacementProfile,
|
||||
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
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
[HttpDelete("education/{personalId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteEducation(Guid personalId)
|
||||
{
|
||||
var education = await _context.PlacementEducations.FirstOrDefaultAsync(x => x.Id == personalId);
|
||||
if (education == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
_context.PlacementEducations.Remove(education);
|
||||
_context.SaveChanges();
|
||||
return Success();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue