public ActionResult LanguagePicker(string returnUrl) { LanguagePickerFormData languagePickerFormData = new LanguagePickerFormData { Languages = this.GetAvailableLanguages().ToArray(), ReturnUrl = returnUrl }; return this.PartialView("LanguagePicker", languagePickerFormData); }
public ActionResult LanguagePicker(LanguagePickerFormData languagePickerFormData) { if (!String.IsNullOrEmpty(languagePickerFormData.SelectedLanguage)) { string language = languagePickerFormData.SelectedLanguage.Split(new[] { "-" }, StringSplitOptions.RemoveEmptyEntries)[0]; string culture = languagePickerFormData.SelectedLanguage.Split(new[] { "-" }, StringSplitOptions.RemoveEmptyEntries)[1]; AtomiaCultureInfo atomiaLanguages = new AtomiaCultureInfo { Language = language, Culture = culture }; this.HttpContext.Session["SessionAccountLanguages"] = atomiaLanguages; try { JavaScriptSerializer js = new JavaScriptSerializer(); AtomiaCookieCollection cookieCollection; if (this.Request.Cookies["AtomiaCookieCollection"] != null && !String.IsNullOrEmpty(this.Request.Cookies["AtomiaCookieCollection"].Value)) { cookieCollection = js.Deserialize<AtomiaCookieCollection>(this.Request.Cookies["AtomiaCookieCollection"].Value); } else { cookieCollection = new AtomiaCookieCollection(); } AtomiaCookie aCookie = new AtomiaCookie( this.Request.ApplicationPath, this.Request.Url.Host, js.Serialize(atomiaLanguages), "OrderLanguageCookie"); cookieCollection.AddOrUpdateAtomiaCookie(aCookie); string serializedCookieCollection = js.Serialize(cookieCollection); HttpCookie cookie = new HttpCookie("AtomiaCookieCollection") { Value = serializedCookieCollection, Expires = DateTime.Now.AddYears(1) }; if (this.Request.Cookies["AtomiaCookieCollection"] != null && !String.IsNullOrEmpty(this.Request.Cookies["AtomiaCookieCollection"].Value)) { this.Response.Cookies["AtomiaCookieCollection"].Value = cookie.Value; this.Response.Cookies["AtomiaCookieCollection"].Expires = cookie.Expires; } else { this.Response.Cookies.Add(cookie); } try { var service = GeneralHelper.GetPublicOrderService(this.HttpContext.ApplicationInstance.Context); string orderCurrencyResource = LocalizationHelpers.GlobalResource(String.Format("{0}Common, Currency" + languagePickerFormData.SelectedLanguage, this.HttpContext.Session["Theme"])) ?? LocalizationHelpers.GlobalResource(String.Format("{0}Common, Currency", this.HttpContext.Session["Theme"])); this.HttpContext.Session["OrderCurrencyResource"] = orderCurrencyResource; string orderCurrencyCode = "SEK"; if (this.HttpContext.Application["CurrencyCode" + languagePickerFormData.SelectedLanguage] != null && !String.IsNullOrEmpty( (string)this.HttpContext.Application["CurrencyCode" + languagePickerFormData.SelectedLanguage])) { orderCurrencyCode = (string)this.HttpContext.Application["CurrencyCode" + languagePickerFormData.SelectedLanguage]; } this.HttpContext.Session["OrderCurrencyCode"] = orderCurrencyCode; Guid resellerId = ResellerHelper.GetResellerId(); Plugin.DomainSearch.Helpers.DomainSearchHelper.LoadProductsIntoSession(service, Guid.Empty, resellerId, orderCurrencyCode, culture); } catch (Exception ex) { OrderPageLogger.LogOrderPageException(ex); } } catch (Exception ex) { OrderPageLogger.LogOrderPageException(ex); throw; } } // remove lang parameter when using language form string returnUrl = this.FilterReturnUrl(languagePickerFormData.ReturnUrl); this.Response.Redirect(returnUrl); // View does not exist, but redirect wont pass if some View is not called. :/ return this.View("Index"); }