public static IEnumerable <Address> GetCustomerAddresses(int customerID)
        {
            CustomerIdentity ident = null;

            try { ident = Identity.Customer; } catch { } //null-safe for tests
            return(ExigoDAL.GetCustomerAddresses(customerID, (ident != null ? (customerID == ident.CustomerID) : false)));
        }
        public static Customer GetCustomer(int customerID)
        {
            CustomerIdentity ident = null;

            try { ident = Identity.Customer; } catch { } //null-safe for tests
            // If we are getting the report for the current user, than we will want to get it in real time
            return(ExigoDAL.GetCustomer(customerID: customerID, realtime: (ident != null && (customerID == ident.CustomerID))));
        }
        void MvcApplication_PostAuthenticateRequest(object sender, EventArgs e)
        {
            var      authCookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
            var      context    = this.Context.Request.RequestContext.HttpContext;
            Market   market;
            Language language;

            // Set the culture
            if (authCookie != null)
            {
                var identity = CustomerIdentity.Deserialize(authCookie.Value);
                if (identity == null)
                {
                    FormsAuthentication.SignOut();
                    return;
                }
                else
                {
                    HttpContext.Current.User = new GenericPrincipal(identity, null);
                    Context.User             = new GenericPrincipal(identity, null);

                    // set market to user's current market
                    market = Identity.Customer.Market;
                    // get the default language based on user market
                    var defaultLanguage = Identity.Customer.Language;
                    // get the selected culture (default to user's preferred market language)
                    var selectedCultureCode = GlobalUtilities.GetSelectedCultureCode(context, defaultLanguage.CultureCode);
                    // set the language based on selection
                    language = GlobalUtilities.GetLanguage(selectedCultureCode, market);
                }
            }
            else
            {
                // get the market based on selection
                market = GlobalUtilities.GetCurrentMarket(context);
                // get the default language based on market
                var defaultLanguage = GlobalUtilities.GetLanguage(null, market);
                // get the selected culture (default to current market default language)
                var selectedCultureCode = GlobalUtilities.GetSelectedCultureCode(context, defaultLanguage.CultureCode);
                // set the language based on selection
                language = GlobalUtilities.GetLanguage(selectedCultureCode, market);
            }

            // Set the culture (date, number, currency formats)
            GlobalUtilities.SetCurrentCulture(market.CultureCode);
            // set site language
            GlobalUtilities.SetCurrentUICulture(language.CultureCode);
        }
Beispiel #4
0
        void MvcApplication_PostAuthenticateRequest(object sender, EventArgs e)
        {
            var authenticated = false;

            var authCookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];

            // Set the culture
            if (authCookie != null)
            {
                var identity = CustomerIdentity.Deserialize(authCookie.Value);
                if (identity == null)
                {
                    FormsAuthentication.SignOut();
                }
                else
                {
                    authenticated = true;

                    HttpContext.Current.User = new GenericPrincipal(identity, null);
                    Context.User             = new GenericPrincipal(identity, null);


                    // Set the culture codes
                    GlobalUtilities.SetCurrentCulture(Identity.Customer.Market.CultureCode);
                }
            }
            else
            {
                var cultureCookie = HttpContext.Current.Request.Cookies[GlobalSettings.Globalization.LanguageCookieName];
                if (cultureCookie != null && cultureCookie.Value.IsNotNullOrEmpty())
                {
                    GlobalUtilities.SetCurrentCulture(cultureCookie.Value);
                }
            }

            // Set the language
            System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(Exigo.GetSelectedLanguage());
        }