public IViewComponentResult Invoke() { var user = _sysUserService.Queryable().FirstOrDefault(x => x.Id == HttpContext.Session.GetObjectFromJson <SysUserViewModel>("CurrentUser").Id&& x.IsDeleted == false); var viewModel = new TokenCalculatorViewModel();; var ethToBTCRate = CurrencyPairRateHelper.GetCurrencyPairRate(EnumCurrencyPair.ETHBTC.ToString()).Value; viewModel.ETHToTokenRate = (decimal.Parse(_settingService.Queryable().FirstOrDefault(x => x.Name == CPLConstant.BTCToTokenRate).Value)) * ethToBTCRate; viewModel.BTCToTokenRate = 1 / decimal.Parse(_settingService.Queryable().FirstOrDefault(x => x.Name == CPLConstant.BTCToTokenRate).Value); return(View(viewModel)); }
public IViewComponentResult Invoke(int?sysUserId) { int userId = sysUserId ?? HttpContext.Session.GetObjectFromJson <SysUserViewModel>("CurrentUser").Id; var user = _sysUserService.Queryable().FirstOrDefault(x => x.Id == userId); var viewModel = Mapper.Map <RateViewModel>(user); var ethToBTCRate = CurrencyPairRateHelper.GetCurrencyPairRate(EnumCurrencyPair.ETHBTC.ToString()).Value; viewModel.ETHToTokenRate = (1 / decimal.Parse(_settingService.Queryable().FirstOrDefault(x => x.Name == "BTCToTokenRate").Value)) / ethToBTCRate; viewModel.BTCToTokenRate = 1 / decimal.Parse(_settingService.Queryable().FirstOrDefault(x => x.Name == "BTCToTokenRate").Value); viewModel.SysUserId = user.Id; return(View(viewModel)); }
/// <summary> /// Sets the BTC current price. /// </summary> /// <returns></returns> /// <exception cref="NotImplementedException"></exception> public SetBTCCurrentPriceResult SetBTCCurrentPrice() { try { var currentPrice = CurrencyPairRateHelper.GetCurrencyPairRate(EnumCurrencyPair.BTCUSDT.ToString()); CPL.WCF.Misc.BTCCurrentPrice.Price = currentPrice.Value; CPL.WCF.Misc.BTCCurrentPrice.Time = currentPrice.Time; return(new SetBTCCurrentPriceResult { Status = new Status { Code = Status.OkCode, Text = Status.OkText }, Price = CPL.WCF.Misc.BTCCurrentPrice.Price, DateTime = CPL.WCF.Misc.BTCCurrentPrice.Time.ToUnixTimeInSeconds() }); } catch (Exception ex) { if (ex.InnerException?.Message != null) { return new SetBTCCurrentPriceResult { Status = new Status { Code = Status.ExceptionCode, Text = ex.InnerException.Message } } } ; else { return new SetBTCCurrentPriceResult { Status = new Status { Code = Status.ExceptionCode, Text = ex.Message } } }; } } }