Example #1
0
        public OfflineWithdrawResponse WithdrawalRequestSubmit(OfflineWithdrawRequest request)
        {
            var offlineWithdrawResponse           = new OfflineWithdrawResponse();
            var offlineWithdrawalRequestValidator =
                new OfflineWithdrawalRequestValidator(_container, _repository);

            var validationResult = offlineWithdrawalRequestValidator.Validate(request);

            if (!validationResult.IsValid)
            {
                throw new RegoValidationException(validationResult);
            }

            var bankAccount =
                _repository.PlayerBankAccounts.Include(y => y.Player)
                .Include(y => y.Bank)
                .Include(y => y.Player.Brand)
                .SingleOrDefault(y => y.Id == request.PlayerBankAccountId);

            var id = offlineWithdrawResponse.Id = Guid.NewGuid();

            var referenceCode = GenerateTransactionNumber();

            _serviceBus.PublishMessage(
                new WithdrawRequestSubmit
            {
                ActorName           = _actorInfoProvider.Actor.UserName,
                WithdrawId          = id,
                PlayerId            = bankAccount.Player.Id,
                Amount              = request.Amount,
                LockId              = Guid.NewGuid(),
                PlayerBankAccountId = request.PlayerBankAccountId,
                ReferenceCode       = referenceCode,
                RequestedBy         = request.RequestedBy,
                Requested           = DateTimeOffset.Now.ToBrandOffset(bankAccount.Player.Brand.TimezoneId),
                Remarks             = request.Remarks
            });

            return(offlineWithdrawResponse);
        }
Example #2
0
        public ValidationResult ValidateOfflineWithdrawalRequest(OfflineWithdrawRequest data)
        {
            var offlineWithdrawalRequest = new OfflineWithdrawalRequestValidator(_container, _repository);

            return(offlineWithdrawalRequest.Validate(data));
        }