public async Task AddAsync(string clientId, AccountTier tier, KycStatus status, string changer) { ITierUpgradeRequest currentTierRequest = await GetAsync(clientId, tier); DateTime?requestDate = null; if (currentTierRequest != null && status != KycStatus.Pending) { requestDate = currentTierRequest.Date; await _repository.DeletePendingRequestIndexAsync(clientId, currentTierRequest.Tier); } await _repository.AddAsync(clientId, tier, status, date : requestDate); await _auditLogRepository.InsertRecordAsync(clientId, new AuditLogData { BeforeJson = GetStatus(tier, currentTierRequest).ToJson(), AfterJson = (currentTierRequest?.KycStatus == status ? $"{tier}:{status} (updated)" : $"{tier}:{status}").ToJson(), CreatedTime = DateTime.UtcNow, RecordType = AuditRecordType.TierUpgradeRequest, Changer = changer }); switch (status) { case KycStatus.Ok: await _clientAccountClient.ClientAccount.ChangeAccountTierAsync(clientId, new AccountTierRequest { Tier = tier }); break; case KycStatus.Rejected: case KycStatus.RestrictedArea: await _kycStatusService.ChangeKycStatusAsync(clientId, status, nameof(TierUpgradeService)); break; } if (currentTierRequest?.KycStatus != status) { CqrsEngine.PublishEvent(new TierUpgradeRequestChangedEvent { ClientId = clientId, Tier = tier, OldStatus = currentTierRequest?.KycStatus, NewStatus = status }, TierBoundedContext.Name); } }
public async Task <TierUpgradeRequestResponse> GetAsync(string clientId, TierModel tier) { ITierUpgradeRequest result = await _tierUpgradeService.GetAsync(clientId, _mapper.Map <AccountTier>(tier)); return(_mapper.Map <TierUpgradeRequestResponse>(result)); }
private static string GetStatus(AccountTier tier, ITierUpgradeRequest request) { return(request == null ? string.Empty : $"{tier}:{request.KycStatus.ToString()}"); }