แก้ฟิวnull placement education

This commit is contained in:
Kittapath 2023-07-06 15:27:15 +07:00
parent af00016801
commit b7afae1e7d
2 changed files with 21 additions and 15 deletions

View file

@ -712,17 +712,19 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPut("education/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateEducation([FromBody] PersonEducationRequest req, Guid personalId)
{
var education = await _context.PlacementEducations
.Include(x => x.PlacementProfile)
// 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 (education == null)
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
if (req.Id == null)
{
var data = new PlacementEducation
{
PlacementProfile = education.PlacementProfile,
PlacementProfile = profile,
Institute = req.Institute,
Degree = req.Degree,
Field = req.Field,
@ -746,6 +748,10 @@ namespace BMA.EHR.Placement.Service.Controllers
}
else
{
var education = await _context.PlacementEducations
.FirstOrDefaultAsync(x => x.Id == req.Id);
if (education == null)
return Error(GlobalMessages.DataNotFound, 404);
education.Institute = req.Institute;
education.Degree = req.Degree;
education.Field = req.Field;