Example #1
0
        public async Task <IActionResult> GetAvailableMethods()
        {
            var assets = (await _assetsHelper.GetAssetsAvailableToClientAsync(_requestContext.ClientId, _requestContext.PartnerId)).ToList();

            var cryptos = new WithdrawalMethod
            {
                Name   = "Cryptos",
                Assets = assets
                         .Where(x => x.BlockchainWithdrawal)
                         .Select(x => x.Id)
                         .ToList()
            };

            var swift = new WithdrawalMethod
            {
                Name   = "Swift",
                Assets = assets
                         .Where(x => x.SwiftWithdrawal)
                         .Select(x => x.Id)
                         .ToList()
            };

            var model = new WithdrawalMethodsResponse
            {
                WithdrawalMethods = new List <WithdrawalMethod>
                {
                    cryptos,
                    swift
                }
            };

            return(Ok(model));
        }
Example #2
0
        public async Task <IActionResult> GetAvailableMethods()
        {
            var model = new WithdrawalMethodsResponse();

            try
            {
                var assetsTask =
                    _assetsHelper.GetAssetsAvailableToClientAsync(_requestContext.ClientId, _requestContext.PartnerId);
                var pdTask = _personalDataService.GetAsync(_requestContext.ClientId);

                await Task.WhenAll(assetsTask, pdTask);

                var assets = assetsTask.Result.ToList();
                var pd     = pdTask.Result;

                var cryptos = new WithdrawalMethod
                {
                    Name   = "Cryptos",
                    Assets = assets
                             .Where(x => x.BlockchainWithdrawal)
                             .Select(x => x.Id)
                             .ToList()
                };

                var swift = new WithdrawalMethod
                {
                    Name   = "Swift",
                    Assets = assets
                             .Where(x => x.SwiftWithdrawal && (!_blockedWithdawalSettings.AssetByCountry.ContainsKey(x.Id) ||
                                                               !_blockedWithdawalSettings.AssetByCountry[x.Id]
                                                               .Contains(pd.CountryFromPOA,
                                                                         StringComparer.InvariantCultureIgnoreCase)))
                             .Select(x => x.Id)
                             .ToList()
                };

                model.WithdrawalMethods = new List <WithdrawalMethod> {
                    cryptos, swift
                };
            }
            catch (Exception ex)
            {
                _log.Error(ex, "Error getting available methods", context: $"clientId: {_requestContext.ClientId}, partnerId: {_requestContext.PartnerId}");
                model.WithdrawalMethods = new List <WithdrawalMethod>
                {
                    new WithdrawalMethod
                    {
                        Name   = "Cryptos",
                        Assets = Array.Empty <string>()
                    },
                    new WithdrawalMethod
                    {
                        Name   = "Swift",
                        Assets = Array.Empty <string>()
                    }
                };
            }

            return(Ok(model));
        }
Example #3
0
        public RequestWithdrawalResponseModel RequestWithdrawal(double amount, WithdrawalMethod withdrawalMethod)
        {
            IOperation <WithdrawalRequestModel, RequestWithdrawalResponseModel> operation = BotConfigurator.Container.Resolve <Operation <WithdrawalRequestModel, RequestWithdrawalResponseModel> >();
            RequestWithdrawalResponseModel response = operation.DoOperation(Constants.RequestWithdrawal, new WithdrawalRequestModel()
            {
                Amount = amount, WithdrawalMethod = withdrawalMethod
            });

            return(response);
        }
 public WithdrawalApplication CreateApplication(WithdrawalMethod withdrawalMethod, User user, DateTime withdrawalBefore, decimal amount,
                                                string comment)
 {
     try
     {
         return(CreateApplication(withdrawalMethod.Id, user.Id, withdrawalBefore, amount, comment));
     }
     catch (Exception ex)
     {
         LogEventManager.Logger.Error(ex.Message, ex);
         throw;
     }
 }
Example #5
0
        internal static void PopulateDefaultMoneyCtx(DbContext context)
        {
            try
            {
                var user = new User
                {
                    Id       = 1,
                    UserName = "******",
                };
                var user2 = new User
                {
                    Id       = 2,
                    UserName = "******",
                };
                if (!context.Set <User>().Any(it => it.UserName.Equals(user.UserName)))
                {
                    context.Set <User>().AddRange(user, user2);
                }

                var userBalance = new UserMAccount
                {
                    UserId       = user.Id,
                    BlockedMoney = 0,
                    CurrentMoney = 0
                };
                var userBalance2 = new UserMAccount
                {
                    UserId       = user2.Id,
                    BlockedMoney = 0,
                    CurrentMoney = 0
                };
                context.Set <UserMAccount>().AddRange(userBalance, userBalance2);
                PopulateDefaultOrderCtx(context);

                var cashDepositOperationType = new OperationType
                {
                    Code        = "CASHDEPOSIT".ToUpper(),
                    Name        = "Cash Deposit",
                    IsActive    = true,
                    SortOrder   = 0,
                    DateCreated = DateTime.Now
                };
                if (!context.Set <OperationType>().Any(it => it.Code.Equals(cashDepositOperationType.Code)))
                {
                    context.Set <OperationType>().Add(cashDepositOperationType);
                }
                var u2uTransferOperationType = new OperationType
                {
                    Code        = "USERTOUSERTRANSFER".ToUpper(),
                    Name        = "User To User Transfer",
                    IsActive    = true,
                    SortOrder   = 0,
                    DateCreated = DateTime.Now
                };
                if (!context.Set <OperationType>().Any(it => it.Code.Equals(u2uTransferOperationType.Code)))
                {
                    context.Set <OperationType>().Add(u2uTransferOperationType);
                }
                var refillOperationType = new OperationType
                {
                    Code        = "refill".ToUpper(),
                    Name        = "Refill",
                    IsActive    = true,
                    SortOrder   = 0,
                    DateCreated = DateTime.Now
                };
                if (!context.Set <OperationType>().Any(it => it.Code.Equals(refillOperationType.Code)))
                {
                    context.Set <OperationType>().Add(refillOperationType);
                }
                var withdrawalOperationType = new OperationType
                {
                    Code        = "Withdrawal".ToUpper(),
                    Name        = "Withdrawal Of Funds",
                    IsActive    = true,
                    SortOrder   = 0,
                    DateCreated = DateTime.Now
                };
                if (!context.Set <OperationType>().Any(it => it.Code.Equals(withdrawalOperationType.Code)))
                {
                    context.Set <OperationType>().Add(withdrawalOperationType);
                }
                var courierMethod = new WithdrawalMethod
                {
                    Code        = "courier".ToUpper(),
                    Name        = "Withdraw by a Courier",
                    IsActive    = true,
                    Description = "Default",
                    SortOrder   = 0,
                    DateCreated = DateTime.Now
                };
                if (!context.Set <WithdrawalMethod>().Any(it => it.Code.Equals(courierMethod.Code)))
                {
                    context.Set <WithdrawalMethod>().Add(courierMethod);
                }
                var creditCardMethod = new WithdrawalMethod
                {
                    Code     = "creditCard".ToUpper(),
                    Name     = "Credit Card",
                    IsActive = true,

                    Description = "Default",
                    SortOrder   = 0,
                    DateCreated = DateTime.Now
                };
                if (!context.Set <WithdrawalMethod>().Any(it => it.Code.Equals(creditCardMethod.Code)))
                {
                    context.Set <WithdrawalMethod>().Add(creditCardMethod);
                }
                var testWithdrawalApplication = GenerateWithdrawalApplication(user, creditCardMethod);
                context.Set <WithdrawalApplication>().Add(testWithdrawalApplication);
                context.Set <WithdrawalApplication>().Add(GenerateWithdrawalApplication(user, creditCardMethod));
                context.Set <WithdrawalApplication>().Add(GenerateWithdrawalApplication(user, courierMethod));
                context.Set <WithdrawalApplication>().Add(GenerateWithdrawalApplication(user, courierMethod));
                context.Set <WithdrawalApplication>().Add(GenerateWithdrawalApplication(user, courierMethod));
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                LogEventManager.Logger.Error(ex.Message, ex);
                throw;
            }
        }
Example #6
0
 internal static WithdrawalApplication GenerateWithdrawalApplication(User user, WithdrawalMethod method)
 {
     return(new WithdrawalApplication
     {
         WithdrawalBefore = DateTime.Now.AddDays(14),
         Amount = 1000,
         Comment = "Test Test",
         IsApproved = false,
         DateCreated = DateTime.Now,
         UserId = user.Id,
         WithdrawalMethodId = method.Id
     });
 }