Exemple #1
0
 public RedirectToRouteResult Add(PageTemplate template)
 {
     _service.Add(template);
     return(RedirectToAction("Index"));
 }
Exemple #2
0
        public LayoutModel Setup(MediaModel mediaModel)
        {
            var layoutModel = new LayoutModel();
            //base layout
            var baseLayout = new Layout
            {
                Name        = "Base Ecommerce Layout",
                UrlSegment  = "_BaseEcommerceLayout",
                LayoutAreas = new List <LayoutArea>(),
            };

            _documentService.AddDocument(baseLayout);

            //ecommerce main layout
            var eCommerceLayout = new Layout
            {
                Name        = "Ecommerce Layout",
                UrlSegment  = "_EcommerceLayout",
                LayoutAreas = new List <LayoutArea>(),
                Parent      = baseLayout
            };
            var ecommerceLayoutArea = new List <LayoutArea>
            {
                new LayoutArea {
                    AreaName = "Header Left", Layout = eCommerceLayout
                },
                new LayoutArea {
                    AreaName = "Header Middle", Layout = eCommerceLayout
                },
                new LayoutArea {
                    AreaName = "Header Right", Layout = eCommerceLayout
                },
                new LayoutArea {
                    AreaName = "User Links", Layout = eCommerceLayout
                },
                new LayoutArea {
                    AreaName = "Navigation", Layout = eCommerceLayout
                },
                new LayoutArea {
                    AreaName = "Before Content", Layout = eCommerceLayout
                },
                new LayoutArea {
                    AreaName = "After Content", Layout = eCommerceLayout
                },
                new LayoutArea {
                    AreaName = "Footer Area 1", Layout = eCommerceLayout
                },
                new LayoutArea {
                    AreaName = "Footer Area 2", Layout = eCommerceLayout
                },
                new LayoutArea {
                    AreaName = "Footer Area 3", Layout = eCommerceLayout
                },
                new LayoutArea {
                    AreaName = "Footer Area 4", Layout = eCommerceLayout
                }
            };

            _documentService.AddDocument(eCommerceLayout);
            foreach (LayoutArea area in ecommerceLayoutArea)
            {
                _layoutAreaAdminService.SaveArea(area);
            }

            layoutModel.EcommerceLayout = eCommerceLayout;

            var homeLayout = new Layout
            {
                Name        = "Home Layout",
                UrlSegment  = "_HomeLayout",
                LayoutAreas = new List <LayoutArea>(),
                Parent      = eCommerceLayout
            };
            var homeLayoutAreas = new List <LayoutArea>
            {
                new LayoutArea {
                    AreaName = "Home After Content", Layout = homeLayout
                },
                new LayoutArea {
                    AreaName = "Teaser1", Layout = homeLayout
                },
                new LayoutArea {
                    AreaName = "Teaser2", Layout = homeLayout
                },
                new LayoutArea {
                    AreaName = "Teaser3", Layout = homeLayout
                },
                new LayoutArea {
                    AreaName = "Teaser4", Layout = homeLayout
                }
            };

            _documentService.AddDocument(homeLayout);
            foreach (LayoutArea area in homeLayoutAreas)
            {
                _layoutAreaAdminService.SaveArea(area);
            }
            layoutModel.HomeLayout = homeLayout;
            //checkout layout
            var checkoutLayout = new Layout
            {
                Name        = "Checkout Layout",
                UrlSegment  = "_CheckoutLayout",
                LayoutAreas = new List <LayoutArea>(),
                Parent      = eCommerceLayout
            };
            var checkoutLayoutAreas = new List <LayoutArea>
            {
                new LayoutArea {
                    AreaName = "Checkout Header Left", Layout = checkoutLayout
                },
                new LayoutArea {
                    AreaName = "Checkout Header Middle", Layout = checkoutLayout
                },
                new LayoutArea {
                    AreaName = "Checkout Header Right", Layout = checkoutLayout
                },
                new LayoutArea {
                    AreaName = "Checkout Footer Left", Layout = checkoutLayout
                },
                new LayoutArea {
                    AreaName = "Checkout Footer Right", Layout = checkoutLayout
                }
            };

            _documentService.AddDocument(checkoutLayout);

            foreach (LayoutArea area in checkoutLayoutAreas)
            {
                _layoutAreaAdminService.SaveArea(area);
            }
            layoutModel.CheckoutLayout = checkoutLayout;
            //product layout
            var productLayout = new Layout
            {
                Name        = "Product Layout",
                UrlSegment  = "_ProductLayout",
                LayoutAreas = new List <LayoutArea>(),
                Parent      = eCommerceLayout
            };
            var productLayoutAreas = new List <LayoutArea>
            {
                new LayoutArea {
                    AreaName = "Below Product Price", Layout = productLayout
                },
                new LayoutArea {
                    AreaName = "Below Add to cart", Layout = productLayout
                },
                new LayoutArea {
                    AreaName = "Below Product Information", Layout = productLayout
                },
                new LayoutArea {
                    AreaName = "Before Product Content", Layout = productLayout
                },
                new LayoutArea {
                    AreaName = "After Product Content", Layout = productLayout
                }
            };

            _documentService.AddDocument(productLayout);
            foreach (LayoutArea area in productLayoutAreas)
            {
                _layoutAreaAdminService.SaveArea(area);
            }
            layoutModel.ProductLayout = productLayout;
            //category/search layout
            var searchLayout = new Layout
            {
                Name        = "Search Layout",
                UrlSegment  = "_SearchLayout",
                LayoutAreas = new List <LayoutArea>(),
                Parent      = eCommerceLayout
            };
            var searchLayoutAreas = new List <LayoutArea>
            {
                new LayoutArea {
                    AreaName = "Before Filters", Layout = searchLayout
                },
                new LayoutArea {
                    AreaName = "After Filters", Layout = searchLayout
                }
            };

            _documentService.AddDocument(searchLayout);
            foreach (LayoutArea area in searchLayoutAreas)
            {
                _layoutAreaAdminService.SaveArea(area);
            }
            layoutModel.SearchLayout = searchLayout;

            var contentLayout = new Layout
            {
                Name        = "Content Layout",
                UrlSegment  = "_ContentLayout",
                LayoutAreas = new List <LayoutArea>(),
                Parent      = eCommerceLayout
            };

            _documentService.AddDocument(contentLayout);
            layoutModel.ContentLayout = contentLayout;

            // UserAccount
            var userAccountLayout = new Layout
            {
                Name        = "User Account Layout",
                UrlSegment  = "_UserAccountLayout",
                LayoutAreas = new List <LayoutArea>(),
                Parent      = eCommerceLayout
            };
            var userAccountAreas = new List <LayoutArea>
            {
                new LayoutArea {
                    AreaName = "Right Column", Layout = userAccountLayout
                }
            };

            _documentService.AddDocument(userAccountLayout);
            foreach (LayoutArea area in userAccountAreas)
            {
                _layoutAreaAdminService.SaveArea(area);
            }
            layoutModel.UserAccountLayout = userAccountLayout;

            //Page templates
            var homeTemplate = new PageTemplate
            {
                Name             = "Home Page",
                PageType         = typeof(TextPage).FullName,
                UrlGeneratorType = typeof(DefaultWebpageUrlGenerator).FullName,
                Layout           = homeLayout
            };

            _pageTemplateAdminService.Add(homeTemplate);

            SetPageDefaults(layoutModel);

            return(layoutModel);
        }