コード例 #1
0
ファイル: HomeController.cs プロジェクト: obaidaltaf/CoinTree
        public IActionResult PullCryptoList()
        {
            DataTableParams dataTableParams = new DataTableParams();

            dataTableParams.start       = Convert.ToInt32(Request.Form["start"]);
            dataTableParams.length      = Convert.ToInt32(Request.Form["length"]);
            dataTableParams.draw        = Convert.ToInt32(Request.Form["draw"]);
            dataTableParams.searchValue = Request.Form["search[value]"];
            CryptoRatesViewModel cryptoRatesViewModel = _businessLogic.GetCryptoRate(dataTableParams);

            return(Json(new { data = cryptoRatesViewModel.CryptoRatesList, draw = dataTableParams.draw, recordsTotal = cryptoRatesViewModel.DataTableParams.totalRows, recordsFiltered = cryptoRatesViewModel.DataTableParams.totalRowsAfterfiltering }));
        }
コード例 #2
0
        public async Task <ActionResult> Index(CryptoRatesViewModel currency)
        {
            var currencies = await Mediator.Send(new GetAllCryptoCurrenciesQuery()).ConfigureAwait(false);

            ViewBag.AllCurrencies = currencies.Select(t => new SelectListItem
            {
                Text  = t.Name,
                Value = t.Symbol,
            });

            var prices = await Mediator.Send(new GetCryptoCurrencyExchangeRatesQuery { Symbol = currency.SelectedCryptoCurrency }).ConfigureAwait(false);

            CryptoRatesViewModel model = new CryptoRatesViewModel {
                Prices = prices
            };

            return(View(model));
        }
コード例 #3
0
 public CryptoRatesViewModel getCryptoRate(DataTableParams dataTableParams)
 {
     try
     {
         CryptoRatesViewModel cvm = new CryptoRatesViewModel();
         cvm.CryptoRatesList           = context.CryptoRates.AsNoTracking().ToList();
         cvm.DataTableParams.totalRows = cvm.CryptoRatesList.Count();
         if (!string.IsNullOrEmpty(dataTableParams.searchValue))
         {
             cvm.CryptoRatesList = cvm.CryptoRatesList.
                                   Where(x => x.buy.ToLower().Contains(dataTableParams.searchValue.ToLower())).ToList();
         }
         cvm.DataTableParams.totalRowsAfterfiltering = cvm.CryptoRatesList.Count;
         cvm.CryptoRatesList = cvm.CryptoRatesList.Skip(dataTableParams.start).Take(dataTableParams.length).ToList();
         return(cvm);
     }
     catch (Exception ex)
     {
         throw ex;
         //Log exception
     }
 }