public List <MerchantWalletDTO> GetMerchantWalletList(Guid merchantAccountId)
        {
            var account    = new MerchantAccountDAC().GetById(merchantAccountId);
            var cryptoList = new CryptocurrencyDAC().GetAllActived();

            cryptoList.MoveTop(t => t.Code == FIIICOIN_CODE);

            var pos = new POSDAC().GetById(account.POSId.Value);

            if (!pos.IsWhiteLabel)
            {
                cryptoList.RemoveAll(t => t.IsWhiteLabel == 1);
            }
            else
            {
                cryptoList.MoveTop(t => t.Code == pos.FirstCrypto);
            }

            var walletList   = new MerchantWalletDAC().GetByAccountId(merchantAccountId);
            var currencyId   = new CurrenciesDAC().GetByCode(account.FiatCurrency).ID;
            var exchangeRate = new PriceInfoDAC().GetByCurrencyId(currencyId).ToDictionary(item => item.CryptoID);

            return(cryptoList.Select(e =>
            {
                var wallet = walletList.FirstOrDefault(w => w.CryptoId == e.Id);
                return new MerchantWalletDTO
                {
                    WalletId = wallet?.Id ?? 0,
                    CryptoId = e.Id,
                    CryptoStatus = e.Status,
                    CryptoCode = e.Code,
                    CryptoName = e.Name,
                    IconURL = e.IconURL,
                    DecimalPlace = e.DecimalPlace,
                    Balance = (wallet?.Balance ?? 0).ToString(e.DecimalPlace),
                    FrozenBalance = (wallet?.FrozenBalance ?? 0).ToString(e.DecimalPlace),
                    FiatExchangeRate = (exchangeRate.ContainsKey(e.Id) ? exchangeRate[e.Id].Price : 0m).ToString(4),
                    FiatBalance = (((wallet?.Balance ?? 0) + (wallet?.FrozenBalance ?? 0)) * (exchangeRate.ContainsKey(e.Id) ? exchangeRate[e.Id].Price : 0m)).ToString(4),
                    FiatCode = account.FiatCurrency,
                    CryptoEnable = e.Enable
                };
            }).ToList());
        }
Example #2
0
        public IEnumerable <BillerCryptoItemOM> GetBillerCryptoCurrency(UserAccount user, string fiatCurrency)
        {
            var dac      = new MasterSettingDAC();
            var discount = dac.SelectByGroup("BillerMaxAmount").First(item =>
                                                                      item.Name.Equals("DiscountRate", StringComparison.CurrentCultureIgnoreCase));

            var coins = new UserWalletComponent().ListForDepositAndWithdrawal(user, fiatCurrency).List;

            var priceInfoDict = new PriceInfoDAC().GetByCurrencyId(new CurrenciesDAC().GetByCode(fiatCurrency).ID).ToDictionary(item => item.CryptoID);

            foreach (var item in coins)
            {
                var model = new BillerCryptoItemOM()
                {
                    Code           = item.Code,
                    Id             = item.Id,
                    Name           = item.Name,
                    CryptoEnable   = item.CryptoEnable,
                    DecimalPlace   = item.DecimalPlace,
                    FiatBalance    = item.FiatBalance,
                    FrozenBalance  = item.FrozenBalance,
                    IconUrl        = item.IconUrl,
                    NewStatus      = item.NewStatus,
                    UseableBalance = item.UseableBalance,
                    ExchangeRate   = priceInfoDict.ContainsKey(item.Id) ? priceInfoDict[item.Id].Price.ToString(4) : 0.ToString()
                };
                if (item.Code.Equals("fiii", StringComparison.InvariantCultureIgnoreCase))
                {
                    model.Discount = decimal.Parse(discount.Value).ToString();
                    yield return(model);
                }
                else
                {
                    model.Discount = "0";
                    yield return(model);
                }
            }
        }
        public MerchantWalletDTO GetWalletInfoById(Guid accountId, int cryptoId)
        {
            var crypto       = new CryptocurrencyDAC().GetById(cryptoId);
            var wallet       = new MerchantWalletDAC().GetByAccountId(accountId, cryptoId);
            var merchant     = new MerchantAccountDAC().GetById(accountId);
            var currencyId   = new CurrenciesDAC().GetByCode(merchant.FiatCurrency).ID;
            var exchangeRate = new PriceInfoDAC().GetByCurrencyId(currencyId).ToDictionary(item => item.CryptoID);

            return(new MerchantWalletDTO
            {
                WalletId = wallet?.Id ?? 0,
                CryptoId = crypto.Id,
                CryptoCode = crypto.Code,
                CryptoName = crypto.Name,
                IconURL = crypto.IconURL,
                DecimalPlace = crypto.DecimalPlace,
                Balance = (wallet?.Balance ?? 0).ToString(crypto.DecimalPlace),
                FrozenBalance = (wallet?.FrozenBalance ?? 0).ToString(crypto.DecimalPlace),
                FiatExchangeRate = (exchangeRate.ContainsKey(crypto.Id) ? exchangeRate[crypto.Id].Price : 0m).ToString(4),
                FiatBalance = (((wallet?.Balance ?? 0) + (wallet?.FrozenBalance ?? 0)) * (exchangeRate.ContainsKey(crypto.Id) ? exchangeRate[crypto.Id].Price : 0m)).ToString(4),
                FiatCode = merchant.FiatCurrency
            });
        }