Beispiel #1
0
        public PrePayOM PrePay(UserAccount user, PrePayIM im)
        {
            var merchantAccount = GetMerchantAccountByIdOrCode(im.MerchantId, im.MerchantCode);
            var userWallets     = new UserWalletDAC().GetUserWallets(user.Id);
            var merchantWallets = new MerchantWalletDAC().GetByAccountId(merchantAccount.Id);
            var coins           = new CryptocurrencyDAC().GetAllActived();
            var priceList       = new PriceInfoDAC().GetPrice(merchantAccount.FiatCurrency);

            bool showWhiteLable = false;

            if (merchantAccount.POSId.HasValue)
            {
                var pos = new POSDAC().GetById(merchantAccount.POSId.Value);
                if (pos.IsWhiteLabel)
                {
                    showWhiteLable = true;
                }
            }

            if (!showWhiteLable)
            {
                var whilteLabelCryptoCode = new POSDAC().GetWhiteLabelCryptoCode();
                coins.RemoveAll(t => t.Code == whilteLabelCryptoCode);
            }

            return(new PrePayOM
            {
                FiatCurrency = merchantAccount.FiatCurrency,
                MarkupRate = merchantAccount.Markup.ToString(CultureInfo.InvariantCulture),
                WaletList = coins.Select(a =>
                {
                    var userWallet = userWallets.FirstOrDefault(b => b.CryptoId == a.Id);
                    decimal rate = 0;
                    rate = priceList.Where(t => t.CryptoID == a.Id).Select(t => t.Price).FirstOrDefault();
                    return GetItem(userWallet, a, merchantWallets, rate);
                }).OrderByDescending(a => a.MerchantSupported).ThenBy(a => a.PayRank).Select(a => new WalletItem
                {
                    Code = a.Code,
                    NewStatus = a.NewStatus,
                    ExchangeRate = a.ExchangeRate,
                    FrozenBalance = a.FrozenBalance,
                    IconUrl = a.IconUrl,
                    Id = a.Id,
                    MerchantSupported = a.MerchantSupported,
                    Name = a.Name,
                    UseableBalance = a.UseableBalance,
                    FiatBalance = a.FiatBalance,
                    DecimalPlace = a.DecimalPlace,
                    CryptoEnable = a.CryptoEnable
                }).ToList()
            });
        }
Beispiel #2
0
        public IndexOM Index(UserAccount user)
        {
            try
            {
                var isBillerEnable   = bool.Parse(new MasterSettingDAC().Single("BillerMaxAmount", "BillerEnable").Value);
                var userWallets      = new UserWalletDAC().GetUserWallets(user.Id);
                var currencyId       = new CurrenciesDAC().GetByCode(user.FiatCurrency).ID;
                var exchangeRateList = new PriceInfoDAC().GetByCurrencyId(currencyId);
                var exchangeRate     = exchangeRateList.ToDictionary(item => item.CryptoID);
                var coins            = new CryptocurrencyDAC().GetAllActived().OrderBy(e => e.Sequence).ToList();
                var list             = coins.Select(a =>
                {
                    var userWallet = userWallets.FirstOrDefault(b => b.CryptoId == a.Id);
                    var rate       = exchangeRate.ContainsKey(a.Id) ? exchangeRate[a.Id].Price : 0m;
                    return(GetItem(userWallet, a, rate));
                }).Where(a => a.ShowInHomePage)
                                       //.OrderBy(a => a.HomePageRank)
                                       .Select(a => new CurrencyItem
                {
                    Id               = a.Id,
                    Code             = a.Code,
                    NewStatus        = a.NewStatus,
                    FrozenBalance    = a.FrozenBalance,
                    IconUrl          = a.IconUrl,
                    UseableBalance   = a.UseableBalance,
                    FiatBalance      = a.FiatBalance,
                    FiatExchangeRate = exchangeRate.ContainsKey(a.Id) ? exchangeRate[a.Id].Price.ToString(4) : 0m.ToString(4),
                    CryptoEnable     = a.CryptoEnable
                }).ToList();

                return(new IndexOM
                {
                    TotalAmount = GetUserTotalAmount(user, userWallets, coins, exchangeRateList),
                    CurrencyItemList = list,
                    IsLV1Verified = user.L1VerifyStatus == VerifyStatus.Certified,
                    HasSetPin = !string.IsNullOrEmpty(user.Pin),
                    FiatCurrency = user.FiatCurrency,
                    IsBillerEnable = isBillerEnable
                });
            }
            catch (Exception exception)
            {
                Error(exception.StackTrace);
                return(new IndexOM
                {
                    TotalAmount = "--",
                    CurrencyItemList = null,
                    FiatCurrency = user.FiatCurrency
                });
            }
        }
        public ListForDepositOM ListForDepositAndWithdrawal(UserAccount user, string fiatCurrency)
        {
            try
            {
                var userWallets = new UserWalletDAC().GetUserWallets(user.Id);
                var coins       = new CryptocurrencyDAC().GetAllActived().OrderBy(e => e.Sequence);
                //var rates = GetExchangeRates(user.CountryId, user.FiatCurrency);
                var priceList = new PriceInfoDAC().GetPrice(fiatCurrency);
                var list      = coins.Select(a =>
                {
                    var userWallet = userWallets.FirstOrDefault(b => b.CryptoId == a.Id);
                    decimal rate   = 0;
                    if (userWallet != null)
                    {
                        rate = priceList.Where(t => t.CryptoID == userWallet.CryptoId).Select(t => t.Price).FirstOrDefault();
                    }
                    return(GetDepositOMItemTempItem(userWallet, a, rate));
                })
                                //.OrderBy(a => a.PayRank)
                                .Select(a => new ListForDepositOMItem
                {
                    Id             = a.Id,
                    Code           = a.Code,
                    NewStatus      = a.NewStatus,
                    FrozenBalance  = a.FrozenBalance,
                    DecimalPlace   = a.DecimalPlace,
                    IconUrl        = a.IconUrl,
                    FiatBalance    = a.FiatBalance,
                    UseableBalance = a.UseableBalance,
                    Name           = a.Name,
                    CryptoEnable   = a.CryptoEnable
                }).ToList();

                return(new ListForDepositOM
                {
                    FiatCurrency = user.FiatCurrency,
                    List = list
                });
            }
            catch (Exception exception)
            {
                Error(exception.Message);
            }

            return(null);
        }
Beispiel #4
0
        private PrePayOM GetUserPrePayOM(Guid userAccountId, MerchantInformation merchantInfo)
        {
            var userDAC             = new UserAccountDAC();
            var merchantDAC         = new MerchantInformationDAC();
            var merchantUserAccount = userDAC.GetById(merchantInfo.MerchantAccountId);
            var supportList         = new MerchantSupportCryptoDAC().GetList(merchantInfo.Id).ToList();
            var userWallets         = new UserWalletDAC().GetUserWallets(userAccountId);
            var coins     = new CryptocurrencyDAC().GetAllActived();
            var priceList = new PriceInfoDAC().GetPrice(merchantUserAccount.FiatCurrency);

            var whilteLabelCryptoCode = new POSDAC().GetWhiteLabelCryptoCode();

            coins.RemoveAll(t => t.Code == whilteLabelCryptoCode);

            return(new PrePayOM
            {
                FiatCurrency = merchantUserAccount.FiatCurrency,
                MarkupRate = merchantInfo.Markup.ToString(CultureInfo.InvariantCulture),
                WaletList = coins.Select(a =>
                {
                    var userWallet = userWallets.FirstOrDefault(b => b.CryptoId == a.Id);
                    decimal rate = 0;
                    rate = priceList.Where(t => t.CryptoID == a.Id).Select(t => t.Price).FirstOrDefault();
                    return GetUserSupportItem(userWallet, a, supportList, rate);
                }).OrderByDescending(a => a.MerchantSupported).ThenBy(a => a.PayRank).Select(a => new WalletItem
                {
                    Code = a.Code,
                    NewStatus = a.NewStatus,
                    ExchangeRate = a.ExchangeRate,
                    FrozenBalance = a.FrozenBalance,
                    IconUrl = a.IconUrl,
                    Id = a.Id,
                    MerchantSupported = a.MerchantSupported,
                    Name = a.Name,
                    UseableBalance = a.UseableBalance,
                    FiatBalance = a.FiatBalance,
                    DecimalPlace = a.DecimalPlace,
                    CryptoEnable = a.CryptoEnable
                }).ToList()
            });
        }
        public WalletPreReOrderOM PreReOrder(UserAccount user)
        {
            var userWallets = new UserWalletDAC().GetUserWallets(user.Id);
            var coins       = new CryptocurrencyDAC().GetAll();
            var list        = coins.Select(a =>
            {
                var userWallet = userWallets.FirstOrDefault(b => b.CryptoId == a.Id);

                return(GetPreReOrderOMItemTempItem(userWallet, a));
            }).OrderBy(a => a.PayRank).Select(a => new WalletPreReOrderOMItem
            {
                Id      = a.Id,
                Code    = a.Code,
                IconUrl = a.IconUrl,
                Name    = a.Name,
                Fixed   = a.Fixed
            }).ToList();

            return(new WalletPreReOrderOM
            {
                List = list
            });
        }
Beispiel #6
0
        public PreReOrder1OM PreReOrder(UserAccount user)
        {
            var userWallets = new UserWalletDAC().GetUserWallets(user.Id);
            var coins       = new CryptocurrencyDAC().GetAllActived();
            var list        = coins.Select(a =>
            {
                var userWallet = userWallets.FirstOrDefault(b => b.CryptoId == a.Id);

                return(GetPreReOrderOMItemTempItem(userWallet, a));
            }).OrderByDescending(a => a.ShowInHomePage).ThenBy(a => a.HomePageRank).Select(a => new PreReOrder1OMItem
            {
                Id             = a.Id,
                Code           = a.Code,
                IconUrl        = a.IconUrl,
                Name           = a.Name,
                Fixed          = a.Fixed,
                ShowInHomePage = a.ShowInHomePage
            }).ToList();

            return(new PreReOrder1OM
            {
                List = list
            });
        }