From b7afae1e7d7053df6c1624a3749cfe2b57b3a24a Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 6 Jul 2023 15:27:15 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=9F=E0=B8=B4?= =?UTF-8?q?=E0=B8=A7null=20placement=20education?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PlacementController.cs | 14 ++++++++---- .../Requests/PersonEducationRequest.cs | 22 +++++++++---------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 27d91291..a3d585de 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -712,17 +712,19 @@ namespace BMA.EHR.Placement.Service.Controllers [HttpPut("education/{personalId:length(36)}")] public async Task> 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; diff --git a/BMA.EHR.Placement.Service/Requests/PersonEducationRequest.cs b/BMA.EHR.Placement.Service/Requests/PersonEducationRequest.cs index bbaa05ae..dee0e76a 100644 --- a/BMA.EHR.Placement.Service/Requests/PersonEducationRequest.cs +++ b/BMA.EHR.Placement.Service/Requests/PersonEducationRequest.cs @@ -10,18 +10,18 @@ namespace BMA.EHR.Placement.Service.Requests public Guid? Id { get; set; } public Guid? EducationLevelId { get; set; } public Guid? PositionPathId { get; set; } - public string Institute { get; set; } - public string Degree { get; set; } - public string Field { get; set; } - public string Gpa { get; set; } - public string Country { get; set; } - public string Duration { get; set; } + public string? Institute { get; set; } + public string? Degree { get; set; } + public string? Field { get; set; } + public string? Gpa { get; set; } + public string? Country { get; set; } + public string? Duration { get; set; } public int DurationYear { get; set; } - public string Other { get; set; } - public string FundName { get; set; } - public DateTime FinishDate { get; set; } - public DateTime StartDate { get; set; } - public DateTime EndDate { get; set; } + public string? Other { get; set; } + public string? FundName { get; set; } + public DateTime? FinishDate { get; set; } + public DateTime? StartDate { get; set; } + public DateTime? EndDate { get; set; } } } \ No newline at end of file