Пример #1
0
        public void GetLoginTheme(LoginModel model, string brand, string hotel)
        {
            HotelBrand hb = null;

            if (!string.IsNullOrEmpty(brand))
            {
                hb =
                    ProxylessContext.HotelBrands.Include(x => x.HotelBrandImageMaps.Select(y => y.Image)).Include(x => x.LogoOnWhiteImage).FirstOrDefault(x => x.HotelBrandSlugs.Any(y => y.HotelBrandSlugName.ToLower() == brand.ToLower()));

                if (hb != null)
                {
                    if (hb.ThemeColor1.HasValue)
                    {
                        var theme1 = MediaUtilities.ColorFromInt(hb.ThemeColor1.Value);
                        if (theme1 != null)
                        {
                            model.ThemeColor1 = ColorTranslator.ToHtml(theme1.Value);
                        }
                    }
                    if (hb.ThemeColor2.HasValue)
                    {
                        var theme2 = MediaUtilities.ColorFromInt(hb.ThemeColor2.Value);
                        if (theme2 != null)
                        {
                            model.ThemeColor2 = ColorTranslator.ToHtml(theme2.Value);
                        }
                    }
                    if (hb.HotelBrandImageMaps.Any())
                    {
                        model.ThemeImages = hb.HotelBrandImageMaps.Select(x => x.Image).ToList();
                    }
                    if (hb.LogoOnWhiteImage != null)
                    {
                        model.LogoOnWhiteImage = hb.LogoOnWhiteImage;
                    }
                }
            }
            Hotel h = null;

            if (!string.IsNullOrEmpty(hotel))
            {
                h =
                    ProxylessContext.Hotels
                    .Include(x => x.HotelImageMaps.Select(y => y.Image))
                    .Include(x => x.HotelDetail)
                    .Include(x => x.HotelDetail.LogoOnWhiteImage)
                    .FirstOrDefault(x => x.HotelSlugs.Any(y => y.HotelSlugName.ToLower() == hotel.ToLower()));

                if (h != null)
                {
                    if (h.HotelDetail.ThemeColor1.HasValue)
                    {
                        var theme1 = MediaUtilities.ColorFromInt(h.HotelDetail.ThemeColor1.Value);
                        if (theme1 != null)
                        {
                            model.ThemeColor1 = ColorTranslator.ToHtml(theme1.Value);
                        }
                    }
                    if (h.HotelDetail.ThemeColor2.HasValue)
                    {
                        var theme2 = MediaUtilities.ColorFromInt(h.HotelDetail.ThemeColor2.Value);
                        if (theme2 != null)
                        {
                            model.ThemeColor2 = ColorTranslator.ToHtml(theme2.Value);
                        }
                    }
                    if (h.HotelImageMaps.Any())
                    {
                        model.ThemeImages = h.HotelImageMaps.Select(x => x.Image).ToList();
                    }
                    if (h.HotelDetail.LogoOnWhiteImage != null)
                    {
                        model.LogoOnWhiteImage = h.HotelDetail.LogoOnWhiteImage;
                    }
                }
            }

            if (model.ThemeColor1 == null)
            {
                model.ThemeColor1 = "#009cd8";
            }
            if (model.ThemeColor2 == null)
            {
                model.ThemeColor2 = "#008abf";
            }
            if (model.ThemeImages == null)
            {
                model.ThemeImages = new List <Image>
                {
                    new Image {
                        PKID = 773954, Path = "B701632D780EA89A4A612D311CDF4DF0883BB7E8.jpg", Width = 1600, Height = 1000
                    },
                    new Image {
                        PKID = 773955, Path = "191620E574A337AE1F7E11EA8378F5AFB03203CF.jpg", Width = 1600, Height = 1000
                    },
                    new Image {
                        PKID = 773956, Path = "598CCF5D989F40D7B2C66EF7B1694C9E9EF15AE1.jpg", Width = 1600, Height = 1000
                    },
                    new Image {
                        PKID = 773957, Path = "5D9B5B360F0B0A9D4A574EEE951C98D2928A71FE.jpg", Width = 1600, Height = 1000
                    }
                }
            }
            ;
            if (model.LogoOnWhiteImage == null)
            {
                model.LogoOnWhiteImage = new Image {
                    PKID = 773958, Path = "309655E0AF902B6CECCEF2CBE68C1777FA0754DD.png", Width = 540, Height = 90
                }
            }
            ;

            var customCreateAccountLinks = new Dictionary <string, string>
            {
                { "dolce", "https://signup.monscierge.com/Plans/Full?brand=dolce" },
                { "ibis", "https://signup.monscierge.com/Plans/Full?brand=ibis" },
                { "novotel", "https://signup.monscierge.com/Plans/Full?brand=novotel" },
                { "ihg", "https://signup.monscierge.com/Plans/Full?brand=ihg" },
                { "warwick", "https://signup.monscierge.com/Custom/Warwick" },
                { "wyndham", "https://signup.monscierge.com/Plans/Full?brand=wyndham" },
                { "banyantree", "https://signup.monscierge.com/Plans/Full?brand=banyantree" },
                { "nordic", "https://signup.monscierge.com/Plans/Full?brand=nordicchoice" },
                { "bestwestern", "https://signup.monscierge.com/Plans/Full?brand=bestwestern" },
                { "parkinn", "https://signup.monscierge.com/Plans/Full?brand=parkinn" },
                { "carlsonrezidor", "https://signup.monscierge.com/Plans/Full?brand=carlsonrezidor" }
            };

            model.CreateAccountUrl = brand != null && customCreateAccountLinks.ContainsKey(brand) ? customCreateAccountLinks[brand] : "https://signup.monscierge.com";
        }