diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index 8e69fa4d..6692422e 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -688,5 +688,74 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + [HttpPut("education/{personalId:length(36)}")] + public async Task> 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> 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(); + } + } } diff --git a/BMA.EHR.Placement.Service/Requests/PersonEducationRequest.cs b/BMA.EHR.Placement.Service/Requests/PersonEducationRequest.cs index 9b7f7559..bbaa05ae 100644 --- a/BMA.EHR.Placement.Service/Requests/PersonEducationRequest.cs +++ b/BMA.EHR.Placement.Service/Requests/PersonEducationRequest.cs @@ -5,7 +5,23 @@ namespace BMA.EHR.Placement.Service.Requests { public class PersonEducationRequest { - public string Name { get; set; } - public bool Value { get; set; } + //public string Name { get; set; } + //public bool Value { get; set; } + 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 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; } + } -} +} \ No newline at end of file