public ActionResult Create(CreateOfflineDepositRequest request)
        {
            var response = GetAdminApiProxy(Request).CreateOfflineDeposit(request);

            return(response.Success
                ? this.Success(response.Id)
                : this.Failed(response.Errors));
        }
        public async Task <CreateOfflineDepositResponse> Create(CreateOfflineDepositRequest request)
        {
            VerifyPermission(Permissions.Create, Modules.OfflineDepositRequests);

            var player = _paymentQueries.GetPlayer(request.PlayerId);

            CheckBrand(player.BrandId);

            var command = Mapper.Map <OfflineDepositRequest>(request);

            //TODO: This is a temporary solution. We need to have unified way of returning validation errors
            //TODO: The problem specifically for 'PaymentSettingsViolatedException' is that it doesn't use FluentValidation.
            //TODO: PaymentSettingsValidator.cs has to be replaced with FluentValidation in order to fall under the common pattern that we use.
            OfflineDeposit response;

            try
            {
                response = await _offlineDepositCommands.Submit(command);
            }
            catch (PaymentSettingsViolatedException ex)
            {
                var errors = new List <ValidationError> {
                    new ValidationError
                    {
                        ErrorMessage = ex.Message
                    }
                };

                return(new CreateOfflineDepositResponse()
                {
                    Success = false,
                    Errors = errors
                });
            }

            return(new CreateOfflineDepositResponse
            {
                Success = true,
                Id = response.Id
            });
        }
Beispiel #3
0
 public CreateOfflineDepositResponse CreateOfflineDeposit(CreateOfflineDepositRequest request)
 {
     return(WebClient.SecurePostAsJson <CreateOfflineDepositRequest, CreateOfflineDepositResponse>(Token, _url + AdminApiRoutes.CreateOfflineDeposit, request));
 }