ปรับ api ข้อมูลประวัติการศึกษา
This commit is contained in:
parent
b7afae1e7d
commit
c6dc582254
2 changed files with 22 additions and 9 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
|
|
@ -715,16 +716,25 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
// var education = await _context.PlacementEducations
|
||||
// .Include(x => x.PlacementProfile)
|
||||
// .FirstOrDefaultAsync(x => x.Id == personalId);
|
||||
var profile = await _context.PlacementProfiles
|
||||
.FirstOrDefaultAsync(x => x.Id == personalId);
|
||||
var profile = await _context.PlacementProfiles.FirstOrDefaultAsync(x => x.Id == personalId);
|
||||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
var educationLevel = await _context.EducationLevels.FirstOrDefaultAsync(x => x.Id == req.EducationLevelId);
|
||||
if (educationLevel == null && req.EducationLevelId != null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
var positionPath = await _context.PositionPaths.FirstOrDefaultAsync(x => x.Id == req.PositionPathId);
|
||||
if (positionPath == null && req.PositionPathId != null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
|
||||
if (req.Id == null)
|
||||
{
|
||||
var data = new PlacementEducation
|
||||
{
|
||||
PlacementProfile = profile,
|
||||
EducationLevel = educationLevel,
|
||||
PositionPath = positionPath,
|
||||
Institute = req.Institute,
|
||||
Degree = req.Degree,
|
||||
Field = req.Field,
|
||||
|
|
@ -748,10 +758,12 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
var education = await _context.PlacementEducations
|
||||
.FirstOrDefaultAsync(x => x.Id == req.Id);
|
||||
var education = await _context.PlacementEducations.FirstOrDefaultAsync(x => x.Id == req.Id);
|
||||
if (education == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
return Error(GlobalMessages.EducationNotFound, 404);
|
||||
|
||||
education.EducationLevel = educationLevel;
|
||||
education.PositionPath = positionPath;
|
||||
education.Institute = req.Institute;
|
||||
education.Degree = req.Degree;
|
||||
education.Field = req.Field;
|
||||
|
|
@ -772,12 +784,12 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
[HttpDelete("education/{personalId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteEducation(Guid personalId)
|
||||
[HttpDelete("education/{educationId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> DeleteEducation(Guid educationId)
|
||||
{
|
||||
var education = await _context.PlacementEducations.FirstOrDefaultAsync(x => x.Id == personalId);
|
||||
var education = await _context.PlacementEducations.FirstOrDefaultAsync(x => x.Id == educationId);
|
||||
if (education == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
return Error(GlobalMessages.EducationNotFound, 404);
|
||||
|
||||
_context.PlacementEducations.Remove(education);
|
||||
_context.SaveChanges();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue