fix #1357 ปรับ API
This commit is contained in:
parent
7b55e16e7d
commit
88270a230f
6 changed files with 20839 additions and 27 deletions
|
|
@ -8745,6 +8745,23 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<Guid?> GetRequestIdByTypeAsync(Guid period, Guid ocId, string type = "officer")
|
||||
{
|
||||
try
|
||||
{
|
||||
var req = await _dbContext.Set<InsigniaRequest>()
|
||||
.Where(x => x.OrganizationId != null)
|
||||
.FirstOrDefaultAsync(x => x.Period.Id == period && x.OrganizationId == ocId && x.ProfileType.ToLower() == type.ToLower());
|
||||
if (req == null)
|
||||
return null;
|
||||
return req.Id;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// Save Aprove
|
||||
public async Task SaveAprove(Guid period, Guid ocId)
|
||||
{
|
||||
|
|
@ -8771,6 +8788,31 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task SaveApproveByTypeAsync(Guid period, Guid ocId, string type = "officer")
|
||||
{
|
||||
try
|
||||
{
|
||||
var req = await GetRequestIdByTypeAsync(period, ocId, type);
|
||||
|
||||
if (req != null)
|
||||
{
|
||||
var insigniaRequestProfiles = await _dbContext.Set<InsigniaRequestProfile>()
|
||||
.Where(x => x.Request.Id == req)
|
||||
.ToListAsync();
|
||||
foreach (var insigniaRequestProfile in insigniaRequestProfiles)
|
||||
{
|
||||
insigniaRequestProfile.IsApprove = true;
|
||||
}
|
||||
}
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// เช็คข้อมูล ใน table insignia_request_new
|
||||
public async Task<InsigniaResults?> GetInsigniaRequest(Guid id, Guid ocId)
|
||||
{
|
||||
|
|
@ -8820,6 +8862,54 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<InsigniaResults?> GetInsigniaRequestByTypeAsync(Guid id, Guid ocId, string type = "officer")
|
||||
{
|
||||
try
|
||||
{
|
||||
var period = await _dbContext.Set<InsigniaPeriod>()
|
||||
.Select(p => new
|
||||
{
|
||||
Id = p.Id,
|
||||
Name = p.Name,
|
||||
Round = p.Round,
|
||||
Year = p.Year,
|
||||
IsLock = p.IsLock,
|
||||
})
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
if (period == null)
|
||||
return null;
|
||||
else
|
||||
{
|
||||
var request = await _dbContext.Set<InsigniaRequest>()
|
||||
.Include(x => x.Document)
|
||||
.FirstOrDefaultAsync(x => x.Period.Id == period.Id && x.OrganizationId == ocId && x.ProfileType.ToLower() == type.ToLower());
|
||||
|
||||
return new InsigniaResults
|
||||
{
|
||||
PeriodId = period.Id,
|
||||
Year = period.Year,
|
||||
Round = period.Round,
|
||||
Name = period.Name,
|
||||
IsLock = period.IsLock,
|
||||
RequestId = request == null ? null : request.Id,
|
||||
RequestNote = request == null ? "" : request.RequestNote,
|
||||
RequestStatus = request == null ? null : request.RequestStatus,
|
||||
OrganizationName = request == null ? "" : request.Organization,
|
||||
Document = request == null
|
||||
? null
|
||||
: (request.Document == null
|
||||
? null
|
||||
: await _documentService.ImagesPath(request.Document.Id)),
|
||||
};
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// Get Data Table insignai_has_profile
|
||||
public async Task<List<InsigniaRequestItem>> InsigniaHasProfile(Guid period, Guid ocId, string status)
|
||||
{
|
||||
|
|
@ -8975,7 +9065,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
|
||||
// insert candidate list
|
||||
|
||||
public async Task UpdateCandidateAsync(Guid periodId, Guid ocId, string oc, List<InsigniaResultSet> items)
|
||||
public async Task UpdateCandidateAsync(Guid periodId, Guid ocId, string oc, List<InsigniaResultSet> items, string type = "officer")
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -8989,6 +9079,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
.Include(x => x.Period)
|
||||
.Where(x => x.Period.Id == periodId)
|
||||
.Where(x => x.OrganizationId == ocId)
|
||||
.Where(x => x.ProfileType.ToLower() == type.ToLower())
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (req != null)
|
||||
|
|
@ -9068,7 +9159,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
|
||||
|
||||
public async Task InsertCandidate(Guid periodId, Guid ocId, string oc, List<InsigniaResultSet> items)
|
||||
public async Task InsertCandidate(Guid periodId, Guid ocId, string oc, List<InsigniaResultSet> items, string type = "officer")
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -9103,6 +9194,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
ProfileType = type
|
||||
};
|
||||
|
||||
foreach (var item in items)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue