api ทดลองงาน list ตำแหน่ง
This commit is contained in:
parent
5dc317b9f6
commit
3332af583b
1 changed files with 60 additions and 1 deletions
|
|
@ -77,7 +77,9 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
[HttpGet("exam/{year}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetExam(int year)
|
||||
{
|
||||
var data = await _context.Placements.Where(x => year > 0 ? (x.Year == year) : (x.Year > 0)).Select(x => new
|
||||
var data = await _context.Placements.Where(x => year > 0 ? (x.Year == year) : (x.Year > 0))
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Id,
|
||||
ExamRound = x.Name,
|
||||
|
|
@ -1115,5 +1117,62 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
return Success();
|
||||
}
|
||||
|
||||
[HttpGet("user/{personalId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> GetUserByOrganization(Guid personalId)
|
||||
{
|
||||
var profile = await _context.Profiles
|
||||
.FirstOrDefaultAsync(x => x.Id == personalId);
|
||||
if (profile == null)
|
||||
return Error(GlobalMessages.DataNotFound, 404);
|
||||
var organization = await _context.Organizations
|
||||
.Include(x => x.Parent)
|
||||
.FirstOrDefaultAsync(x => x.Id == profile.OcId);
|
||||
if (organization == null)
|
||||
return Error(GlobalMessages.OrganizationNotFound, 404);
|
||||
var profilePosition = await _context.ProfilePositions
|
||||
.Where(x => x.Profile != null)
|
||||
.Where(x => x.OrganizationPosition != null)
|
||||
.Where(x => x.OrganizationPosition.PositionMaster != null)
|
||||
.Where(x => x.Profile != profile)
|
||||
.Where(x => x.OrganizationPosition.Organization == organization)
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Profile.Id,
|
||||
Prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
|
||||
FirstName = x.Profile.FirstName,
|
||||
LastName = x.Profile.LastName,
|
||||
CitizenId = x.Profile.CitizenId,
|
||||
IsDirector = x.OrganizationPosition.PositionMaster.IsDirector,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var caregiver = profilePosition.Where(x => x.IsDirector == false).ToList();
|
||||
var commander = profilePosition.Where(x => x.IsDirector == true).ToList();
|
||||
|
||||
if (organization.Parent != null)
|
||||
{
|
||||
var profilePositionHigh = await _context.ProfilePositions
|
||||
.Where(x => x.Profile != null)
|
||||
.Where(x => x.OrganizationPosition != null)
|
||||
.Where(x => x.OrganizationPosition.PositionMaster != null)
|
||||
.Where(x => x.Profile != profile)
|
||||
.Where(x => x.OrganizationPosition.Organization == organization.Parent)
|
||||
.Select(x => new
|
||||
{
|
||||
Id = x.Profile.Id,
|
||||
Prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
|
||||
FirstName = x.Profile.FirstName,
|
||||
LastName = x.Profile.LastName,
|
||||
CitizenId = x.Profile.CitizenId,
|
||||
IsDirector = x.OrganizationPosition.PositionMaster.IsDirector,
|
||||
})
|
||||
.ToListAsync();
|
||||
var chairman = profilePositionHigh.Where(x => x.IsDirector == true).ToList();
|
||||
return Success(new { caregiver, commander, chairman });
|
||||
}
|
||||
|
||||
return Success(new { caregiver, commander, chairman = new List<dynamic>() });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue