public async Task <IViewComponentResult> InvokeAsync(string type, string category) { string culture = ""; string currency = ""; //currency = HttpContext.Request.Query["currency"].ToString().ToUpper(); //currency = MShopClass.getCurrency(currency); //culture = MShopClass.currencyList()[currency.ToUpper()]; //var cultureSet = CultureInfo.GetCultureInfo(culture); //Thread.CurrentThread.CurrentCulture = cultureSet; //Thread.CurrentThread.CurrentUICulture = cultureSet; culture = CultureInfo.CurrentCulture.Name.ToLower(); currency = MShopClass.getCurrency(culture); ViewBag.Culture = CultureInfo.CurrentCulture.Name; //System.Diagnostics.Debug.Print("Current Culture: " + culture + ";"); ViewBag.Dollar = currency; return(View(await this.GetProducts(type, category, currency))); }
public async Task <IViewComponentResult> InvokeAsync() { var cart = SessionHelper.GetObjectFromJson <List <ShoppingCartItemModel> >(HttpContext.Session, "cart"); if (cart == null) { cart = new List <ShoppingCartItemModel>(); } string culture = CultureInfo.CurrentCulture.Name.ToLower(); string currency = ""; //currency = HttpContext.Request.Query["currency"].ToString().ToUpper(); currency = MShopClass.getCurrency(culture); //culture = MShopClass.currencyList()[currency.ToUpper()]; // culture = MShopClass.currencyList()[currency.ToUpper()]; float exchangeRate = 1; if ((currency != "") && (currency.ToUpper() != "NZD")) { exchangeRate = CurrencyConvertor.GetExchangeRate(currency); } ViewBag.Culture = culture; ViewBag.Currency = currency; ViewBag.ExchangeRate = exchangeRate; ViewBag.cart = cart; ViewBag.total = cart.Sum(ShoppingCartItem => ShoppingCartItem.Product.ProductPrice * ShoppingCartItem.Quantity); return(View()); }