แก้apiแต่งตั้งลูกจ้าง

This commit is contained in:
Kittapath 2023-10-04 09:42:45 +07:00
parent e5efe02ad1
commit 788055d358
2 changed files with 16 additions and 16 deletions

View file

@ -63,7 +63,7 @@ namespace BMA.EHR.Placement.Service.Controllers
{ {
var placementAppointments = await _context.PlacementAppointments.AsQueryable() var placementAppointments = await _context.PlacementAppointments.AsQueryable()
.Where(x => (x.Profile.ProfileType == "EMPLOYEE" && x.Profile.EmployeeClass == "PREM") || (x.Profile.ProfileType == "OFFICER")) .Where(x => (x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm") || (x.Profile.ProfileType == "officer"))
.OrderByDescending(x => x.CreatedAt) .OrderByDescending(x => x.CreatedAt)
.Select(p => new .Select(p => new
{ {
@ -124,7 +124,7 @@ namespace BMA.EHR.Placement.Service.Controllers
public async Task<ActionResult<ResponseObject>> GetDetailByUser(Guid id) public async Task<ActionResult<ResponseObject>> GetDetailByUser(Guid id)
{ {
var data = await _context.PlacementAppointments.AsQueryable() var data = await _context.PlacementAppointments.AsQueryable()
.Where(x => (x.Profile.ProfileType == "EMPLOYEE" && x.Profile.EmployeeClass == "PREM") || (x.Profile.ProfileType == "OFFICER")) .Where(x => (x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm") || (x.Profile.ProfileType == "officer"))
.Where(x => x.Id == id) .Where(x => x.Id == id)
.Select(p => new .Select(p => new
{ {
@ -244,7 +244,7 @@ namespace BMA.EHR.Placement.Service.Controllers
.Include(x => x.Position) .Include(x => x.Position)
.Include(x => x.Gender) .Include(x => x.Gender)
.Include(x => x.Prefix) .Include(x => x.Prefix)
.Where(x => (x.ProfileType == "EMPLOYEE" && x.EmployeeClass == "PREM") || (x.ProfileType == "OFFICER")) .Where(x => (x.ProfileType == "employee" && x.EmployeeClass == "perm") || (x.ProfileType == "officer"))
.FirstOrDefaultAsync(x => x.Id == req.Id); .FirstOrDefaultAsync(x => x.Id == req.Id);
if (profile == null) if (profile == null)
return Error(GlobalMessages.DataNotFound, 404); return Error(GlobalMessages.DataNotFound, 404);
@ -326,7 +326,7 @@ namespace BMA.EHR.Placement.Service.Controllers
public async Task<ActionResult<ResponseObject>> UpdatePositionPlacementAppointment([FromBody] PersonSelectPositionAppointmentRequest req, Guid id) public async Task<ActionResult<ResponseObject>> UpdatePositionPlacementAppointment([FromBody] PersonSelectPositionAppointmentRequest req, Guid id)
{ {
var uppdated = await _context.PlacementAppointments var uppdated = await _context.PlacementAppointments
.Where(x => (x.Profile.ProfileType == "EMPLOYEE" && x.Profile.EmployeeClass == "PREM") || (x.Profile.ProfileType == "OFFICER")) .Where(x => (x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm") || (x.Profile.ProfileType == "officer"))
.FirstOrDefaultAsync(x => x.Id == id); .FirstOrDefaultAsync(x => x.Id == id);
if (uppdated == null) if (uppdated == null)
return Error(GlobalMessages.PlacementAppointmentNotFound, 404); return Error(GlobalMessages.PlacementAppointmentNotFound, 404);
@ -406,7 +406,7 @@ namespace BMA.EHR.Placement.Service.Controllers
public async Task<ActionResult<ResponseObject>> Put([FromBody] PlacementAppointmentEditRequest req, Guid id) public async Task<ActionResult<ResponseObject>> Put([FromBody] PlacementAppointmentEditRequest req, Guid id)
{ {
var uppdated = await _context.PlacementAppointments var uppdated = await _context.PlacementAppointments
.Where(x => (x.Profile.ProfileType == "EMPLOYEE" && x.Profile.EmployeeClass == "PREM") || (x.Profile.ProfileType == "OFFICER")) .Where(x => (x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm") || (x.Profile.ProfileType == "officer"))
.FirstOrDefaultAsync(x => x.Id == id); .FirstOrDefaultAsync(x => x.Id == id);
if (uppdated == null) if (uppdated == null)
return Error(GlobalMessages.PlacementAppointmentNotFound, 404); return Error(GlobalMessages.PlacementAppointmentNotFound, 404);
@ -489,7 +489,7 @@ namespace BMA.EHR.Placement.Service.Controllers
var deleted = await _context.PlacementAppointments.AsQueryable() var deleted = await _context.PlacementAppointments.AsQueryable()
.Include(x => x.PlacementAppointmentDocs) .Include(x => x.PlacementAppointmentDocs)
.ThenInclude(x => x.Document) .ThenInclude(x => x.Document)
.Where(x => (x.Profile.ProfileType == "EMPLOYEE" && x.Profile.EmployeeClass == "PREM") || (x.Profile.ProfileType == "OFFICER")) .Where(x => (x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm") || (x.Profile.ProfileType == "officer"))
.FirstOrDefaultAsync(x => x.Id == id); .FirstOrDefaultAsync(x => x.Id == id);
if (deleted == null) if (deleted == null)
return NotFound(); return NotFound();
@ -526,7 +526,7 @@ namespace BMA.EHR.Placement.Service.Controllers
foreach (var item in req.Id) foreach (var item in req.Id)
{ {
var uppdated = await _context.PlacementAppointments var uppdated = await _context.PlacementAppointments
.Where(x => (x.Profile.ProfileType == "EMPLOYEE" && x.Profile.EmployeeClass == "PREM") || (x.Profile.ProfileType == "OFFICER")) .Where(x => (x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm") || (x.Profile.ProfileType == "officer"))
.FirstOrDefaultAsync(x => x.Id == item); .FirstOrDefaultAsync(x => x.Id == item);
if (uppdated == null) if (uppdated == null)
continue; continue;
@ -556,7 +556,7 @@ namespace BMA.EHR.Placement.Service.Controllers
{ {
var appointments = await _context.PlacementAppointments var appointments = await _context.PlacementAppointments
.Where(x => x.PositionNumber != null) .Where(x => x.PositionNumber != null)
.Where(x => (x.Profile.ProfileType == "EMPLOYEE" && x.Profile.EmployeeClass == "PREM") || (x.Profile.ProfileType == "OFFICER")) .Where(x => (x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm") || (x.Profile.ProfileType == "officer"))
.Select(x => x.PositionNumber.Id) .Select(x => x.PositionNumber.Id)
.ToListAsync(); .ToListAsync();

View file

@ -64,7 +64,7 @@ namespace BMA.EHR.Placement.Service.Controllers
var placementAppointments = await _context.PlacementAppointments.AsQueryable() var placementAppointments = await _context.PlacementAppointments.AsQueryable()
.OrderByDescending(x => x.CreatedAt) .OrderByDescending(x => x.CreatedAt)
.Where(x => x.Profile.ProfileType == "EMPLOYEE" && x.Profile.EmployeeClass == "TEMP") .Where(x => x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm")
.Select(p => new .Select(p => new
{ {
p.Id, p.Id,
@ -127,7 +127,7 @@ namespace BMA.EHR.Placement.Service.Controllers
{ {
var data = await _context.PlacementAppointments.AsQueryable() var data = await _context.PlacementAppointments.AsQueryable()
.Where(x => x.Id == id) .Where(x => x.Id == id)
.Where(x => x.Profile.ProfileType == "EMPLOYEE" && x.Profile.EmployeeClass == "TEMP") .Where(x => x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm")
.Select(p => new .Select(p => new
{ {
p.Id, p.Id,
@ -246,7 +246,7 @@ namespace BMA.EHR.Placement.Service.Controllers
.Include(x => x.Position) .Include(x => x.Position)
.Include(x => x.Gender) .Include(x => x.Gender)
.Include(x => x.Prefix) .Include(x => x.Prefix)
.Where(x => x.ProfileType == "EMPLOYEE" && x.EmployeeClass == "TEMP") .Where(x => x.ProfileType == "employee" && x.EmployeeClass == "perm")
.FirstOrDefaultAsync(x => x.Id == req.Id); .FirstOrDefaultAsync(x => x.Id == req.Id);
if (profile == null) if (profile == null)
return Error(GlobalMessages.DataNotFound, 404); return Error(GlobalMessages.DataNotFound, 404);
@ -328,7 +328,7 @@ namespace BMA.EHR.Placement.Service.Controllers
public async Task<ActionResult<ResponseObject>> UpdatePositionPlacementAppointment([FromBody] PersonSelectPositionAppointmentRequest req, Guid id) public async Task<ActionResult<ResponseObject>> UpdatePositionPlacementAppointment([FromBody] PersonSelectPositionAppointmentRequest req, Guid id)
{ {
var uppdated = await _context.PlacementAppointments var uppdated = await _context.PlacementAppointments
.Where(x => x.Profile.ProfileType == "EMPLOYEE" && x.Profile.EmployeeClass == "TEMP") .Where(x => x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm")
.FirstOrDefaultAsync(x => x.Id == id); .FirstOrDefaultAsync(x => x.Id == id);
if (uppdated == null) if (uppdated == null)
return Error(GlobalMessages.PlacementAppointmentNotFound, 404); return Error(GlobalMessages.PlacementAppointmentNotFound, 404);
@ -408,7 +408,7 @@ namespace BMA.EHR.Placement.Service.Controllers
public async Task<ActionResult<ResponseObject>> Put([FromBody] PlacementAppointmentEditRequest req, Guid id) public async Task<ActionResult<ResponseObject>> Put([FromBody] PlacementAppointmentEditRequest req, Guid id)
{ {
var uppdated = await _context.PlacementAppointments var uppdated = await _context.PlacementAppointments
.Where(x => x.Profile.ProfileType == "EMPLOYEE" && x.Profile.EmployeeClass == "TEMP") .Where(x => x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm")
.FirstOrDefaultAsync(x => x.Id == id); .FirstOrDefaultAsync(x => x.Id == id);
if (uppdated == null) if (uppdated == null)
return Error(GlobalMessages.PlacementAppointmentNotFound, 404); return Error(GlobalMessages.PlacementAppointmentNotFound, 404);
@ -491,7 +491,7 @@ namespace BMA.EHR.Placement.Service.Controllers
var deleted = await _context.PlacementAppointments.AsQueryable() var deleted = await _context.PlacementAppointments.AsQueryable()
.Include(x => x.PlacementAppointmentDocs) .Include(x => x.PlacementAppointmentDocs)
.ThenInclude(x => x.Document) .ThenInclude(x => x.Document)
.Where(x => x.Profile.ProfileType == "EMPLOYEE" && x.Profile.EmployeeClass == "TEMP") .Where(x => x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm")
.FirstOrDefaultAsync(x => x.Id == id); .FirstOrDefaultAsync(x => x.Id == id);
if (deleted == null) if (deleted == null)
return NotFound(); return NotFound();
@ -528,7 +528,7 @@ namespace BMA.EHR.Placement.Service.Controllers
foreach (var item in req.Id) foreach (var item in req.Id)
{ {
var uppdated = await _context.PlacementAppointments var uppdated = await _context.PlacementAppointments
.Where(x => x.Profile.ProfileType == "EMPLOYEE" && x.Profile.EmployeeClass == "TEMP") .Where(x => x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm")
.FirstOrDefaultAsync(x => x.Id == item); .FirstOrDefaultAsync(x => x.Id == item);
if (uppdated == null) if (uppdated == null)
continue; continue;
@ -558,7 +558,7 @@ namespace BMA.EHR.Placement.Service.Controllers
{ {
var appointments = await _context.PlacementAppointments var appointments = await _context.PlacementAppointments
.Where(x => x.PositionNumber != null) .Where(x => x.PositionNumber != null)
.Where(x => x.Profile.ProfileType == "EMPLOYEE" && x.Profile.EmployeeClass == "TEMP") .Where(x => x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm")
.Select(x => x.PositionNumber.Id) .Select(x => x.PositionNumber.Id)
.ToListAsync(); .ToListAsync();