private void SetupHomeLayoutWidgets(PageModel pageModel, MediaModel mediaModel, LayoutModel layoutModel)
        {
            var layout        = layoutModel.HomeLayout;
            var beforeContent = layoutModel.EcommerceLayout.LayoutAreas.FirstOrDefault(x => x.AreaName == "Before Content");
            var teaser1Area   = layout.LayoutAreas.FirstOrDefault(x => x.AreaName == "Teaser1");
            var teaser2Area   = layout.LayoutAreas.FirstOrDefault(x => x.AreaName == "Teaser2");
            var teaser3Area   = layout.LayoutAreas.FirstOrDefault(x => x.AreaName == "Teaser3");
            var teaser4Area   = layout.LayoutAreas.FirstOrDefault(x => x.AreaName == "Teaser4");

            var slider = new Slider
            {
                Image           = mediaModel.SliderImage1.FileUrl,
                Image1          = mediaModel.SliderImage2.FileUrl,
                LayoutArea      = beforeContent,
                Webpage         = pageModel.HomePage,
                Cache           = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength     = 1800
            };

            _widgetService.AddWidget(slider);

            var featuredProducts = new FeaturedProducts
            {
                LayoutArea             = beforeContent,
                Webpage                = pageModel.HomePage,
                ListOfFeaturedProducts = GetFeaturedProducts(),
                Name            = "Featured Products",
                Cache           = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength     = 1800
            };

            _widgetService.AddWidget(featuredProducts);

            //nav
            var nav = new MobileFriendlyNavigation.Widgets.MobileFriendlyNavigation
            {
                Name            = "Navigation",
                LayoutArea      = layoutModel.EcommerceLayout.LayoutAreas.First(x => x.AreaName == ("Navigation")),
                IncludeChildren = true,
                Cache           = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength     = 60
            };

            _widgetService.AddWidget(nav);

            var featuredCategories = new FeaturedCategories
            {
                LayoutArea = beforeContent,
                Webpage    = pageModel.HomePage,
                ListOfFeaturedCategories = GetFeaturedCategories(),
                Name            = "Featured Categories",
                Cache           = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength     = 1800
            };

            _widgetService.AddWidget(featuredCategories);

            var teaser1 = new TextWidget()
            {
                LayoutArea      = teaser1Area,
                Webpage         = pageModel.HomePage,
                Text            = string.Format(@"<div class=""padding-bottom-10""><span><img src=""{0}"" /> </span></div><h3><a href=""#"">FREE delivery on orders over &pound;50. </a></h3><p>Orders placed Monday to Friday before 2pm will generally be picked and packed for immediate despatch. Please note that orders placed over the weekend or on public holidays will be processed on the next working day.</p>", mediaModel.DeliveryIcon.FileUrl),
                Cache           = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength     = 1800
            };

            _widgetService.AddWidget(teaser1);

            var teaser2 = new TextWidget()
            {
                LayoutArea      = teaser2Area,
                Webpage         = pageModel.HomePage,
                Text            = string.Format(@"<div class=""padding-bottom-10""><span><img src=""{0}"" /> </span></div><h3><a href=""#"">7 day no question returns.</a></h3><p>We offer a 28 Day Money Back Guarantee. If for any reason you are not completely delighted with your purchase you may download a Returns Form and return it within 28 days of receipt for a full refund or exchange.</p>", mediaModel.ReturnIcon.FileUrl),
                Cache           = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength     = 1800
            };

            _widgetService.AddWidget(teaser2);

            var teaser3 = new TextWidget()
            {
                LayoutArea      = teaser3Area,
                Webpage         = pageModel.HomePage,
                Text            = string.Format(@"<div class=""padding-bottom-10""><span><img src=""{0}"" /> </span></div><h3><a href=""#"">Store locations.</a></h3><p>Use our store locator to find a store near you as well as information like opening times, addresses, maps and a list of facilities available at every store.</p>", mediaModel.LocationIcon.FileUrl),
                Cache           = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength     = 1800
            };

            _widgetService.AddWidget(teaser3);

            var teaser4 = new TextWidget()
            {
                LayoutArea      = teaser4Area,
                Webpage         = pageModel.HomePage,
                Text            = string.Format(@"<div class=""padding-bottom-10""><span><img src=""{0}"" /> </span></div><h3><a href=""#"">Contact us.</a></h3><p>Our customer service team is always willing to answer your proposal concerning Samsung Service. Your message will be promptly handled under the direct supervision of our executive management.</p>", mediaModel.ContactIcon.FileUrl),
                Cache           = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength     = 60
            };

            _widgetService.AddWidget(teaser4);

            GetFormProperties(pageModel.HomePage);
            //home footer form
            var footerLinksWidgetForm = new TextWidget
            {
                LayoutArea      = layoutModel.EcommerceLayout.LayoutAreas.First(x => x.AreaName == "Footer Area 4"),
                Name            = "Footer links",
                Text            = string.Format("[form-{0}]", pageModel.HomePage.Id),
                Cache           = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength     = 60
            };

            _widgetService.AddWidget(footerLinksWidgetForm);
        }
Esempio n. 2
0
        private void SetupHomeLayoutWidgets(PageModel pageModel, MediaModel mediaModel, LayoutModel layoutModel)
        {
            var layout = layoutModel.HomeLayout;
            var beforeContent = layoutModel.EcommerceLayout.LayoutAreas.FirstOrDefault(x => x.AreaName == "Before Content");
            var teaser1Area = layout.LayoutAreas.FirstOrDefault(x => x.AreaName == "Teaser1");
            var teaser2Area = layout.LayoutAreas.FirstOrDefault(x => x.AreaName == "Teaser2");
            var teaser3Area = layout.LayoutAreas.FirstOrDefault(x => x.AreaName == "Teaser3");
            var teaser4Area = layout.LayoutAreas.FirstOrDefault(x => x.AreaName == "Teaser4");

            var slider = new Slider
            {
                Image = mediaModel.SliderImage1.FileUrl,
                Image1 = mediaModel.SliderImage2.FileUrl,
                LayoutArea = beforeContent,
                Webpage = pageModel.HomePage,
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 1800
            };
            _widgetService.AddWidget(slider);

            var featuredProducts = new FeaturedProducts
            {
                LayoutArea = beforeContent,
                Webpage = pageModel.HomePage,
                ListOfFeaturedProducts = GetFeaturedProducts(),
                Name = "Featured Products",
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 1800
            };
            _widgetService.AddWidget(featuredProducts);

            //nav
            var nav = new MobileFriendlyNavigation.Widgets.MobileFriendlyNavigation
            {
                Name = "Navigation",
                LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.Single(x => x.AreaName == ("Navigation")),
                IncludeChildren = true,
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 60
            };
            _widgetService.AddWidget(nav);

            var featuredCategories = new FeaturedCategories
            {
                LayoutArea = beforeContent,
                Webpage = pageModel.HomePage,
                ListOfFeaturedCategories = GetFeaturedCategories(),
                Name = "Featured Categories",
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 1800
            };
            _widgetService.AddWidget(featuredCategories);

            var teaser1 = new TextWidget()
            {
                LayoutArea = teaser1Area,
                Webpage = pageModel.HomePage,
                Text = string.Format(@"<div class=""padding-bottom-10""><span><img src=""{0}"" /> </span></div><h3><a href=""#"">FREE delivery on orders over &pound;50. </a></h3><p>Orders placed Monday to Friday before 2pm will generally be picked and packed for immediate despatch. Please note that orders placed over the weekend or on public holidays will be processed on the next working day.</p>", mediaModel.DeliveryIcon.FileUrl),
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 1800
                
            };
            _widgetService.AddWidget(teaser1);

            var teaser2 = new TextWidget()
            {
                LayoutArea = teaser2Area,
                Webpage = pageModel.HomePage,
                Text = string.Format(@"<div class=""padding-bottom-10""><span><img src=""{0}"" /> </span></div><h3><a href=""#"">7 day no question returns.</a></h3><p>We offer a 28 Day Money Back Guarantee. If for any reason you are not completely delighted with your purchase you may download a Returns Form and return it within 28 days of receipt for a full refund or exchange.</p>", mediaModel.ReturnIcon.FileUrl),
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 1800
                
            };
            _widgetService.AddWidget(teaser2);

            var teaser3 = new TextWidget()
            {
                LayoutArea = teaser3Area,
                Webpage = pageModel.HomePage,
                Text = string.Format(@"<div class=""padding-bottom-10""><span><img src=""{0}"" /> </span></div><h3><a href=""#"">Store locations.</a></h3><p>Use our store locator to find a store near you as well as information like opening times, addresses, maps and a list of facilities available at every store.</p>", mediaModel.LocationIcon.FileUrl),
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 1800
                
            };
            _widgetService.AddWidget(teaser3);

            var teaser4 = new TextWidget()
            {
                LayoutArea = teaser4Area,
                Webpage = pageModel.HomePage,
                Text = string.Format(@"<div class=""padding-bottom-10""><span><img src=""{0}"" /> </span></div><h3><a href=""#"">Contact us.</a></h3><p>Our customer service team is always willing to answer your proposal concerning Samsung Service. Your message will be promptly handled under the direct supervision of our executive management.</p>", mediaModel.ContactIcon.FileUrl),
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 60
            };
            _widgetService.AddWidget(teaser4);

            GetFormProperties(pageModel.HomePage);
            //home footer form
            var footerLinksWidgetForm = new TextWidget
            {
                LayoutArea = layoutModel.EcommerceLayout.LayoutAreas.Single(x => x.AreaName == "Footer Area 4"),
                Name = "Footer links",
                Text = string.Format("[form-{0}]", pageModel.HomePage.Id),
                Cache = true,
                CacheExpiryType = CacheExpiryType.Sliding,
                CacheLength = 60
            };
            _widgetService.AddWidget(footerLinksWidgetForm);
        }