แสดง status คำสั่ง

แก้ไขบั้กเลือกคนแล้วบันทึกไม่ลง
This commit is contained in:
Suphonchai Phoonsawat 2023-08-31 12:13:33 +07:00
parent 89c7b6e239
commit 0ca1a22ea6
2 changed files with 21 additions and 17 deletions

View file

@ -65,7 +65,7 @@ namespace BMA.EHR.Application.Repositories.Commands
#region " List Receiver " #region " List Receiver "
private async Task<List<CommandReceiver>> GetReceiverForByCommndTypeAsync(Command command) public async Task<List<CommandReceiver>> GetReceiverForByCommndTypeAsync(Command command)
{ {
var result = new List<CommandReceiver>(); var result = new List<CommandReceiver>();
@ -708,7 +708,7 @@ namespace BMA.EHR.Application.Repositories.Commands
.ToListAsync(); .ToListAsync();
// 2. Query // 2. Query
var appointPeople = await _dbContext.Set<PlacementTransfer>() var appointPeople = await _dbContext.Set<PlacementTransfer>()
.Include(x => x.Profile) .Include(x => x.Profile)
.ThenInclude(x => x.Prefix) .ThenInclude(x => x.Prefix)
//.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId)
@ -1607,33 +1607,34 @@ namespace BMA.EHR.Application.Repositories.Commands
if (command == null) if (command == null)
throw new Exception(GlobalMessages.CommandNotFound); throw new Exception(GlobalMessages.CommandNotFound);
var appointPeople = await _dbContext.Set<PlacementProfile>() var ap = (await GetReceiverForByCommndTypeAsync(command)).Where(x => selected.Contains(x.RefPlacementProfileId!.Value));
.Include(x => x.Prefix)
.Include(x => x.OrganizationPosition) //var appointPeople = await _dbContext.Set<PlacementProfile>()
.ThenInclude(x => x!.Organization) // .Include(x => x.Prefix)
//.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId) // .Include(x => x.OrganizationPosition)
.Where(x => selected.Contains(x.Id)) // .ThenInclude(x => x!.Organization)
.OrderBy(x => x.ExamNumber) // //.Where(x => x.OrganizationPosition!.Organization!.Id == command.OwnerGovId)
.ToListAsync(); // .Where(x => selected.Contains(x.Id))
// .OrderBy(x => x.ExamNumber)
// .ToListAsync();
_dbContext.Set<CommandReceiver>().RemoveRange(command.Receivers); _dbContext.Set<CommandReceiver>().RemoveRange(command.Receivers);
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync();
var seq = 1; var seq = 1;
foreach (var item in appointPeople) foreach (var item in ap)
{ {
var receiver = new CommandReceiver var receiver = new CommandReceiver
{ {
Sequence = seq, Sequence = seq,
CitizenId = item.CitizenId!, CitizenId = item.CitizenId!,
Prefix = item.Prefix!.Name, Prefix = item.Prefix,
FirstName = item.Firstname!, FirstName = item.FirstName!,
LastName = item.Lastname!, LastName = item.LastName!,
RefPlacementProfileId = item.Id RefPlacementProfileId = item.RefPlacementProfileId
}; };
seq++;
seq++;
command.Receivers.Add(receiver); command.Receivers.Add(receiver);
} }
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync();

View file

@ -393,6 +393,9 @@ namespace BMA.EHR.Command.Service.Controllers
conclusionFireDate = data.ConclusionFireDate, conclusionFireDate = data.ConclusionFireDate,
conclusionFireResolution = data.ConclusionFireResolution, conclusionFireResolution = data.ConclusionFireResolution,
OrderStatusValue = data.CommandStatusId,
OrderStatusName = data.CommandStatus.Name,
}; };
return Success(result); return Success(result);