예제 #1
0
        public OfflineDepositConfirmValidator(
            IPaymentRepository repository,
            IPlayerRepository playerRepository,
            IPaymentQueries paymentQueries)
        {
            _repository       = repository;
            _playerRepository = playerRepository;
            _paymentQueries   = paymentQueries;

            RuleFor(x => x.PlayerAccountName)
            .NotEmpty()
            .WithMessage("FieldIsRequired");

            RuleFor(x => x.Amount).GreaterThan(0).WithMessage("AmountGreaterZero");

            RuleFor(x => x)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .Must(x =>
            {
                var deposit = _repository.OfflineDeposits.Single(o => o.Id == x.Id);

                var player =
                    _playerRepository.Players.Include(y => y.IdentityVerifications)
                    .Single(y => y.Id == deposit.PlayerId);

                return(IsAccountNameValid(x.PlayerAccountName, player) ||
                       (!string.IsNullOrEmpty(x.IdFrontImage) && !string.IsNullOrEmpty(x.IdBackImage)) ||
                       !string.IsNullOrEmpty(x.ReceiptImage));
            })
            .WithMessage("FrontAndBackCopyRequired")
            .WithName("IdFront")
            .Must(x =>
            {
                var deposit = _repository.OfflineDeposits.Single(o => o.Id == x.Id);

                var player =
                    _playerRepository.Players.Include(y => y.IdentityVerifications)
                    .Single(y => y.Id == deposit.PlayerId);

                return(player.IdentityVerifications
                       .Any(
                           o => o.ExpirationDate >= DateTime.Now && o.VerificationStatus == VerificationStatus.Verified) ||
                       (!string.IsNullOrEmpty(x.IdFrontImage) && !string.IsNullOrEmpty(x.IdBackImage)) ||
                       !string.IsNullOrEmpty(x.ReceiptImage));
            })
            .WithMessage("NotActiveIdentificationDocs")
            .WithName("IdFront")
            .Must(x =>
            {
                var bankAccount       = _paymentQueries.GetBankAccountForOfflineDeposit(x.Id);
                var isReceiptRequired = IsReceiptRequiredByPaymentLevelCriterium(x, bankAccount);

                return(!isReceiptRequired || !string.IsNullOrEmpty(x.ReceiptImage));
            })
            .WithMessage("ReceiptRequired")
            .WithName("DepositReceipt");
        }
예제 #2
0
        public BankAccountIdSettings GetBankAccountForOfflineDeposit(Guid offlineDepositId)
        {
            var bankAccount = _paymentQueries.GetBankAccountForOfflineDeposit(offlineDepositId);

            if (bankAccount == null)
            {
                throw new RegoValidationException(ErrorMessagesEnum.BankAccountDoesnNotExistForOfflineDeposit.ToString());
            }

            return(Mapper.DynamicMap <BankAccount, BankAccountIdSettings>(bankAccount));
        }