fix : Add RevisionId For Insignia Period
Some checks failed
release-dev / release-dev (push) Failing after 13s
Some checks failed
release-dev / release-dev (push) Failing after 13s
This commit is contained in:
parent
722a1e33a8
commit
689c425acb
10 changed files with 18272 additions and 63 deletions
|
|
@ -26,18 +26,21 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly InsigniaPeriodsRepository _repository;
|
||||
private readonly NotificationRepository _repositoryNoti;
|
||||
private readonly UserProfileRepository _userProfileRepository;
|
||||
|
||||
public InsigniaPeriodController(ApplicationDBContext context,
|
||||
MinIOService documentService,
|
||||
InsigniaPeriodsRepository repository,
|
||||
NotificationRepository repositoryNoti,
|
||||
IHttpContextAccessor httpContextAccessor)
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
UserProfileRepository userProfileRepository)
|
||||
{
|
||||
_context = context;
|
||||
_documentService = documentService;
|
||||
_repository = repository;
|
||||
_repositoryNoti = repositoryNoti;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_userProfileRepository = userProfileRepository;
|
||||
}
|
||||
|
||||
#region " Properties "
|
||||
|
|
@ -46,6 +49,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
|
||||
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
|
||||
|
||||
private string? AccessToken => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -165,6 +170,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
[HttpPost()]
|
||||
public async Task<ActionResult<ResponseObject>> Post([FromForm] InsigniaPeriodRequest req)
|
||||
{
|
||||
var revisionId = await _userProfileRepository.GetLastRevision(AccessToken);
|
||||
|
||||
var insigniaPeriod = await _context.InsigniaPeriods.AsQueryable()
|
||||
.Where(x => x.Round == req.Round && x.Year == req.Year)
|
||||
.FirstOrDefaultAsync();
|
||||
|
|
@ -186,6 +193,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
|
||||
RevisionId = revisionId ?? Guid.Empty
|
||||
};
|
||||
await _context.InsigniaPeriods.AddAsync(period);
|
||||
await _context.SaveChangesAsync();
|
||||
|
|
|
|||
|
|
@ -558,7 +558,13 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
|
||||
// TODO: original code use this in production
|
||||
|
||||
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken);
|
||||
var selectPeriod = _context.InsigniaPeriods.AsNoTracking().Where(x => x.Id == insigniaPeriodId).FirstOrDefault();
|
||||
if (selectPeriod == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
|
||||
}
|
||||
|
||||
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken, selectPeriod.RevisionId);
|
||||
|
||||
foreach (var organization in organizations)
|
||||
{
|
||||
|
|
@ -974,10 +980,10 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
.Where(x => x.RequestStatus == "st6")
|
||||
.Select(x => x.OrganizationId)
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken);
|
||||
|
||||
|
||||
|
||||
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken, insigniaPeriod.RevisionId);
|
||||
|
||||
var orgAllCount = organizations
|
||||
.Where(x => !orgIdSend.Contains(x.Id))
|
||||
.Select(x => new
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue