ค้นหาผู้เกียวข้องคำสั่ง

This commit is contained in:
DESKTOP-2S5P7D1\Windows 10 2023-09-06 11:52:48 +07:00
parent 83e1e41c62
commit e340beb79d
3 changed files with 27 additions and 21 deletions

View file

@ -3737,28 +3737,34 @@ namespace BMA.EHR.Application.Repositories.Commands
#endregion
public async Task<dynamic> GetCommandProfileAsync(Guid commandTypeId, int year, string? posno)
public async Task<dynamic> GetCommandProfileAsync(string commandType, int year, string? posno)
{
try
{
var commandType = await _dbContext.Set<CommandType>()
.FirstOrDefaultAsync(x => x.Id == commandTypeId);
if (commandType == null)
throw new Exception(GlobalMessages.CommandTypeNotFound);
var profile = await _dbContext.Set<Profile>()
.Where(x => x.CitizenId == "0000000000001")
.Select(x => new
{
Id = x.Id,
CitizenId = x.CitizenId,
FullName = $"{x.Prefix.Name}{x.FirstName} {x.LastName}",
PosNo = x.PosNo == null ? null : x.PosNo.Name,
Position = x.Position == null ? null : x.Position.Name,
})
.ToListAsync();
return profile;
var data = (from r in await _dbContext.Set<ProfileSalary>()
.Include(x => x.Profile)
.ThenInclude(x => x.Prefix)
.Include(x => x.Profile)
.ThenInclude(x => x.PosNo)
.Include(x => x.Profile)
.ThenInclude(x => x.Position)
.ToListAsync()
where r.CommandTypeName == commandType
where r.CommandNo.Contains((year + 543).ToString())
where posno == null || posno == "" ? r.Id != null : r.CommandNo.Contains(posno)
where r.Profile != null
select new
{
Id = r.Profile.Id,
CitizenId = r.Profile.CitizenId,
FullName = $"{r.Profile.Prefix.Name}{r.Profile.FirstName} {r.Profile.LastName}",
PosNo = r.Profile.PosNo == null ? null : r.Profile.PosNo.Name,
Position = r.Profile.Position == null ? null : r.Profile.Position.Name,
})
.Distinct()
.OrderBy(x => x.CitizenId)
.ToList();
return data;
}
catch
{

View file

@ -2,7 +2,7 @@
{
public class SearchProfileCommandRequest
{
public Guid CommandTypeId { get; set; }
public string CommandType { get; set; }
public int Year { get; set; }

View file

@ -3439,7 +3439,7 @@ namespace BMA.EHR.Command.Service.Controllers
{
try
{
var data = await _repository.GetCommandProfileAsync(req.CommandTypeId, req.Year, req.Posno);
var data = await _repository.GetCommandProfileAsync(req.CommandType, req.Year, req.Posno);
return Success(data);
}