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

View file

@ -10,18 +10,18 @@ namespace BMA.EHR.Placement.Service.Requests
public Guid? Id { get; set; } public Guid? Id { get; set; }
public Guid? EducationLevelId { get; set; } public Guid? EducationLevelId { get; set; }
public Guid? PositionPathId { get; set; } public Guid? PositionPathId { get; set; }
public string Institute { get; set; } public string? Institute { get; set; }
public string Degree { get; set; } public string? Degree { get; set; }
public string Field { get; set; } public string? Field { get; set; }
public string Gpa { get; set; } public string? Gpa { get; set; }
public string Country { get; set; } public string? Country { get; set; }
public string Duration { get; set; } public string? Duration { get; set; }
public int DurationYear { get; set; } public int DurationYear { get; set; }
public string Other { get; set; } public string? Other { get; set; }
public string FundName { get; set; } public string? FundName { get; set; }
public DateTime FinishDate { get; set; } public DateTime? FinishDate { get; set; }
public DateTime StartDate { get; set; } public DateTime? StartDate { get; set; }
public DateTime EndDate { get; set; } public DateTime? EndDate { get; set; }
} }
} }