Example #1
0
 public async ValueTask <OperationResponse> UnblockWithdrawalsAsync(ChangeOperationStatusRequest request)
 {
     _logger.LogInformation("Unlocking withdrawal for clientId {clientId}", request.ClientId);
     try
     {
         return(await ChangeOperationStatus(request, false, Operations.Withdrawal));
     }
     catch (Exception e)
     {
         _logger.LogError(e, "When unblocking withdrawal for clientId {clientId}", request.ClientId);
         return(new OperationResponse()
         {
             IsSuccess = false,
             Error = e.Message
         });
     }
 }
Example #2
0
 public async ValueTask <OperationResponse> BlockTradesAsync(ChangeOperationStatusRequest request)
 {
     _logger.LogInformation("Blocking trades for clientId {clientId}", request.ClientId);
     try
     {
         return(await ChangeOperationStatus(request, true, Operations.Trade));
     }
     catch (Exception e)
     {
         _logger.LogError(e, "When blocking trades for clientId {clientId}", request.ClientId);
         return(new OperationResponse()
         {
             IsSuccess = false,
             Error = e.Message
         });
     }
 }
Example #3
0
        private async Task <OperationResponse> ChangeOperationStatus(ChangeOperationStatusRequest request, bool isBlocking, Operations operation)
        {
            var profile = await _repository.GetOrCreateProfile(request.ClientId);

            var oldProfile = (KycProfile)profile.Clone();

            switch (operation)
            {
            case Operations.Deposit:
                profile.DepositStatus = isBlocking ? KycOperationStatus.Blocked : KycOperationStatus.KycRequired;
                break;

            case Operations.Trade:
                profile.TradeStatus = isBlocking ? KycOperationStatus.Blocked : KycOperationStatus.KycRequired;
                break;

            case Operations.Withdrawal:
                profile.WithdrawalStatus = isBlocking ? KycOperationStatus.Blocked : KycOperationStatus.KycRequired;
                break;
            }

            profile.BlockingReason = isBlocking ? request.Comment : String.Empty;

            await _statusSetter.UpdateProfileState(profile);

            await _repository.UpdateProfile(profile, "Manual operation status change", request.Agent, request.Comment);

            await _publisher.PublishAsync(new KycProfileUpdatedMessage()
            {
                ClientId   = request.ClientId,
                OldProfile = oldProfile,
                NewProfile = profile
            });

            return(new OperationResponse()
            {
                IsSuccess = true
            });
        }