api ตำแหน่ง draft

This commit is contained in:
Kittapath 2023-07-19 10:25:54 +07:00
parent 6b7fcaaba2
commit 6a572144ab
42 changed files with 32604 additions and 1 deletions

View file

@ -343,5 +343,37 @@ namespace BMA.EHR.OrganizationEmployee.Service.Controllers
return Success();
}
[HttpGet("position/{profileId:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetPositionEmployee(Guid profileId)
{
var profile = await _context.Profiles.FindAsync(profileId);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
var organizationEmployee = await _context.OrganizationEmployees
.Where(x => x.Profile == null || (x.Profile != null && x.Profile == profile))
.ToListAsync();
return Success(organizationEmployee);
}
[HttpPut("position/{profileId:length(36)}")]
public async Task<ActionResult<ResponseObject>> PutPositionEmployee([FromBody] PositionOrgEmployee req, Guid profileId)
{
var profile = await _context.Profiles.FindAsync(profileId);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
var organizationEmployee = await _context.OrganizationEmployees
.Include(x => x.Profile)
.FirstOrDefaultAsync(x => x.Id == req.OrganizationEmployeeId);
if (organizationEmployee == null)
return Error(GlobalMessages.OrganizationEmployeeNotFound, 404);
organizationEmployee.Profile = profile;
_context.SaveChanges();
return Success();
}
}
}