/// <summary> /// Invoke middleware actions /// </summary> /// <param name="context">HTTP context</param> /// <returns>Task</returns> public async Task InvokeAsync(HttpContext context, IWorkContext workContext) { //set current customer var customer = await workContext.SetCurrentCustomer(); var vendor = await workContext.SetCurrentVendor(customer); var language = await workContext.SetWorkingLanguage(customer); var currency = await workContext.SetWorkingCurrency(customer); var taxtype = await workContext.SetTaxDisplayType(customer); //set culture in admin area if (context.Request.Path.Value.StartsWith("/admin", StringComparison.InvariantCultureIgnoreCase)) { var culture = new CultureInfo("en-US"); CultureInfo.CurrentCulture = culture; CultureInfo.CurrentUICulture = culture; } else { //set culture for customer if (!string.IsNullOrEmpty(language?.LanguageCulture)) { var culture = new CultureInfo(language.LanguageCulture); CultureInfo.CurrentCulture = culture; CultureInfo.CurrentUICulture = culture; } } //call the next middleware in the request pipeline await _next(context); }
/// <summary> /// Invoke middleware actions /// </summary> /// <param name="context">HTTP context</param> /// <returns>Task</returns> public async Task InvokeAsync(HttpContext context, IWorkContext workContext) { //set current customer var customer = await workContext.SetCurrentCustomer(); var vendor = await workContext.SetCurrentVendor(customer); var language = await workContext.SetWorkingLanguage(customer); var currency = await workContext.SetWorkingCurrency(customer); var taxtype = await workContext.SetTaxDisplayType(customer); //call the next middleware in the request pipeline await _next(context); }