api บันทึกเครื่องราช

This commit is contained in:
Kittapath 2023-08-23 20:30:30 +07:00
parent 9abb9c5422
commit 51bdcf4041
50 changed files with 162548 additions and 111 deletions

View file

@ -4801,7 +4801,7 @@ namespace BMA.EHR.Application.Repositories
}
// Save Aprove
public async Task SaveAprove(Guid period, Guid ocId, InsigniaApproveRequest prm)
public async Task SaveAprove(Guid period, Guid ocId)
{
try
{
@ -4809,11 +4809,12 @@ namespace BMA.EHR.Application.Repositories
if (req != null)
{
foreach (var item in prm.Items)
var insigniaRequestProfiles = await _dbContext.Set<InsigniaRequestProfile>()
.Where(x => x.Request.Id == req)
.ToListAsync();
foreach (var insigniaRequestProfile in insigniaRequestProfiles)
{
var approve = await _dbContext.Set<InsigniaRequestProfile>()
.FirstOrDefaultAsync(x => x.Profile.Id == item.ProfileId && x.Request.Id == req);
approve.IsApprove = item.IsApprove;
insigniaRequestProfile.IsApprove = true;
}
}
@ -4835,7 +4836,7 @@ namespace BMA.EHR.Application.Repositories
{
Id = p.Id,
Name = p.Name,
Type = p.Type,
Round = p.Round,
Year = p.Year,
})
.FirstOrDefaultAsync(x => x.Id == id);
@ -4853,7 +4854,8 @@ namespace BMA.EHR.Application.Repositories
return new InsigniaResults
{
PeriodId = period.Id,
Year = period.Year.ToString(),
Year = period.Year,
Round = period.Round,
Name = period.Name,
RequestStatus = request == null ? null : request.RequestStatus,
OrganizationName = request == null ? "" : request.Organization.OrganizationOrganization.Name
@ -4966,6 +4968,7 @@ namespace BMA.EHR.Application.Repositories
.Select(h => new InsigniaRequestItem
{
Id = h.Id,
CitizenId = h.Profile.CitizenId,
ProfileId = h.Profile.Id,
FullName = $"{h.Profile.FirstName} {h.Profile.LastName}",
Position = h.Profile.Position.Name,
@ -5100,6 +5103,17 @@ namespace BMA.EHR.Application.Repositories
if (period == null)
throw new Exception(GlobalMessages.CoinPeriodNotFound);
var periodOlds = await _dbContext.Set<InsigniaPeriod>().Where(p => p.Year == period.Year).ToListAsync();
foreach (var periodOld in periodOlds)
{
var requestOlds = await _dbContext.Set<InsigniaRequest>().Where(p => p.Period == periodOld).ToListAsync();
foreach (var requestOld in requestOlds)
{
var profileOlds = await _dbContext.Set<InsigniaRequestProfile>().Where(p => p.Request == requestOld).Select(x => x.Profile.Id).ToListAsync();
items = items.Where(x => !profileOlds.Contains(x.ProfileId)).ToList();
}
}
var oc = await _dbContext.Set<OrganizationEntity>().FirstOrDefaultAsync(x => x.Id == ocId);
if (oc == null)