Пример #1
0
 /// <summary>
 /// Returns an enumerable collection of menu items ordered by the content tree order and level.
 /// </summary>
 public IEnumerable <TreeNode> GetMenuItems()
 {
     return(pageRetriever.Retrieve <TreeNode>(
                query => query
                .FilterDuplicates()
                .OrderByAscending("NodeLevel", "NodeOrder")
                .MenuItems(),
                cache => cache
                .Key($"{nameof(NavigationRepository)}|{nameof(GetMenuItems)}")
                // Include path dependency to flush cache when a new child page is created or page order is changed.
                .Dependencies((_, builder) => builder.PagePath("/", PathTypeEnum.Children).ObjectType("cms.documenttype").PageOrder())));
 }
Пример #2
0
 /// <summary>
 /// Returns an enumerable collection of articles ordered by the date of publication. The most recent articles come first.
 /// </summary>
 /// <param name="nodeAliasPath">The node alias path of the articles section in the content tree.</param>
 /// <param name="count">The number of articles to return. Use 0 as value to return all records.</param>
 public IEnumerable <Article> GetArticles(string nodeAliasPath, int count = 0)
 {
     return(pageRetriever.Retrieve <Article>(
                query => query
                .Path(nodeAliasPath, PathTypeEnum.Children)
                .TopN(count)
                .OrderByDescending("DocumentPublishFrom"),
                cache => cache
                .Key($"{nameof(ArticleRepository)}|{nameof(GetArticles)}|{nodeAliasPath}|{count}")
                // Include path dependency to flush cache when a new child page is created.
                .Dependencies((_, builder) => builder.PagePath(nodeAliasPath, PathTypeEnum.Children))));
 }
Пример #3
0
 /// <summary>
 /// Returns an enumerable collection of company cafes ordered by a position in the content tree.
 /// </summary>
 /// <param name="nodeAliasPath">The node alias path of the articles section in the content tree.</param>
 /// <param name="count">The number of cafes to return. Use 0 as value to return all records.</param>
 public IEnumerable <Cafe> GetCompanyCafes(string nodeAliasPath, int count = 0)
 {
     return(pageRetriever.Retrieve <Cafe>(
                query => query
                .Path(nodeAliasPath, PathTypeEnum.Children)
                .TopN(count)
                .WhereTrue("CafeIsCompanyCafe")
                .OrderBy("NodeOrder"),
                cache => cache
                .Key($"{nameof(KenticoCafeRepository)}|{nameof(GetCompanyCafes)}|{nodeAliasPath}|{count}")
                // Include path dependency to flush cache when a new child page is created or page order is changed.
                .Dependencies((_, builder) => builder.PagePath(nodeAliasPath, PathTypeEnum.Children).PageOrder())));
 }
        public async Task <IActionResult> Home()
        {
            // Retrieves a page from the Xperience database with the '/Home' node alias path
            var jssHome = _pagesRetriever.Retrieve <TreeNode>(query => query.WithID(PageID)).FirstOrDefault();

            //var jssHome = pages.FirstOrDefault(e => DocumentURLProvider.GetAbsoluteUrl(e).ToLower().Contains("/myblog/jss/home"));

            // Responds with the HTTP 404 error when the page is not found
            if (jssHome == null)
            {
                return(NotFound());
            }

            // Initializes the page data context (and the page builder) using the retrieved page
            _pageDataContextInitializer.Initialize(jssHome);

            //var blogHomePage = _dataRetriever.Retrieve<BlogHome>().Page;
            //var id = blogHomePage.Fields.ID;
            //var title = blogHomePage.Fields.Title;

            var documentQueryHome = BlogHomeProvider.GetBlogHome(NodeGuid, "en-US", "BlogPost");
            var data = documentQueryHome.FirstOrDefault();

            return(View(new BlogHomeViewModel()
            {
                Title = data.BlogHomeTitle
            }));
        }
Пример #5
0
        //EndDocSection:RemoveAllItems


        //DocSection:DetailUrl
        /// <summary>
        /// Redirects to a product detail page based on the ID of a product's SKU object.
        /// </summary>
        /// <param name="skuID">ID of the product's SKU object.</param>
        public IActionResult ItemDetail(int skuID)
        {
            // Gets the SKU object
            SKUInfo sku = skuInfo.Get(skuID);

            // If the SKU does not exist or it is a product option, returns error 404
            if (sku == null || sku.IsProductOption)
            {
                return(NotFound());
            }

            // If the SKU is a product variant, uses its parent product's ID
            if (sku.IsProductVariant)
            {
                skuID = sku.SKUParentSKUID;
            }

            // Gets the product's page
            TreeNode node = pageRetriever.Retrieve <TreeNode>(query => query
                                                              .Culture("en-us")
                                                              .CombineWithDefaultCulture()
                                                              .WhereEquals("NodeSKUID", skuID))
                            .FirstOrDefault();

            // Returns 404 if no page for the specified product exists
            if (node == null)
            {
                return(NotFound());
            }

            // Gets the product page's URL
            string pageUrl = pageUrlRetriever.Retrieve(node).AbsoluteUrl;

            return(Redirect(pageUrl));
        }
Пример #6
0
        public async Task <ActionResult> Index(CancellationToken cancellationToken)
        {
            var pages = _pageRetriever.Retrieve <TreeNode>(query => query
                                                           .Path("/", PathTypeEnum.Children));

            var aboutUsPage = pages.FirstOrDefault(e => DocumentURLProvider.GetAbsoluteUrl(e).ToLower().Contains("/myblog/about"));

            _pageDataContextInitializer.Initialize(aboutUsPage);
            //var aboutUs = _dataRetriever.Retrieve<AboutUs>().Page;

            //var sideStories = await aboutUsRepository.GetSideStoriesAsync(aboutUs.NodeAliasPath, cancellationToken);

            //var reference = (await referenceRepository.GetReferencesAsync($"{aboutUs.NodeAliasPath}/References", cancellationToken, 1)).FirstOrDefault();
            var sideStories = new List <AboutUsSection> ();

            var documentQueryHome = AboutUsProvider.GetAboutUs(NodeGuid, "en-US", "BlogPost");
            var data = documentQueryHome.FirstOrDefault();

            AboutUsViewModel mode = new AboutUsViewModel()
            {
                ID    = data.AboutUsID,
                Title = data.AboutUsText,
                Desc  = data.AboutUsDesc
            };

            return(View(mode));
        }
Пример #7
0
        public IActionResult Index()
        {
            // Retrieves a page from the Xperience database with the '/Home' node alias path
            TreeNode page = _pagesRetriever.Retrieve <TreeNode>(query => query
                                                                .Path("/Home", PathTypeEnum.Single))
                            .FirstOrDefault();

            // Responds with the HTTP 404 error when the page is not found
            if (page == null)
            {
                return(NotFound());
            }

            // Initializes the page data context (and the page builder) using the retrieved page
            _pageDataContextInitializer.Initialize(page);

            var homeSource = HomeProvider.GetHome(Guid.Parse(Home.NodeGuidId), "en-US", "HouseRestaurant");

            var menus  = NavigationProvider.GetMenuItems();
            var dishes = DishProvider.GetDishCategories();

            var vm = new HomeViewModel()
            {
                Id          = homeSource.First().HomeID,
                Description = homeSource.First().Description,
                Title       = homeSource.First().Title,
                MenuItems   = menus,
                Dishes      = dishes
            };


            return(View(vm));
        }
Пример #8
0
        public string GetLatestInsult()
        {
            TreeNode page = pageRetriever.Retrieve <Insult>(query => query
                                                            .TopN(1))
                            .FirstOrDefault();

            return(page.DocumentName);
        }
Пример #9
0
 /// <summary>
 /// Returns company's contact information.
 /// </summary>
 public Contact GetCompanyContact()
 {
     return(pageRetriever.Retrieve <Contact>(
                query => query
                .TopN(1),
                cache => cache
                .Key($"{nameof(ContactRepository)}|{nameof(GetCompanyContact)}"))
            .FirstOrDefault());
 }
Пример #10
0
 /// <summary>
 /// Returns a page with the specified identifier.
 /// </summary>
 /// <param name="nodeGuid">The page node identifier.</param>
 public TreeNode Get(Guid nodeGuid)
 {
     return(pageRetriever.Retrieve <TreeNode>(
                query => query
                .WhereEquals("NodeGUID", nodeGuid),
                cache => cache
                .Key($"{nameof(KenticoPageRepository)}|{nameof(Get)}|{nodeGuid}"))
            .FirstOrDefault());
 }
 /// <summary>
 /// Returns an enumerable collection of links to social networks ordered by a position in the content tree.
 /// </summary>
 public IEnumerable <SocialLink> GetSocialLinks()
 {
     return(pageRetriever.Retrieve <SocialLink>(
                query => query
                .OrderByAscending("NodeOrder"),
                cache => cache
                .Key($"{nameof(KenticoSocialLinkRepository)}|{nameof(GetSocialLinks)}")
                // Include path dependency to flush cache when a new child page is created or page order is changed.
                .Dependencies((_, builder) => builder.Pages(SocialLink.CLASS_NAME).PageOrder())));
 }
 /// <summary>
 /// Returns an enumerable collection of stories about company's philosophy ordered by a position in the content tree.
 /// </summary>
 /// <param name="nodeAliasPath">The node alias path of the About us section in the content tree.</param>
 public IEnumerable <AboutUsSection> GetSideStories(string nodeAliasPath)
 {
     return(pageRetriever.Retrieve <AboutUsSection>(
                query => query
                .Path(nodeAliasPath, PathTypeEnum.Children)
                .OrderBy("NodeOrder"),
                cache => cache
                .Key($"{nameof(KenticoAboutUsRepository)}|{nameof(GetSideStories)}|{nodeAliasPath}")
                // Include path dependency to flush cache when a new child page is created or page order is changed.
                .Dependencies((_, builder) => builder.PagePath(nodeAliasPath, PathTypeEnum.Children).PageOrder())));
 }
 /// <summary>
 /// Returns an enumerable collection of manufacturers.
 /// </summary>
 /// <param name="parentAliasPath">Parent node alias path.</param>
 public IEnumerable <Manufacturer> GetManufacturers(string parentAliasPath)
 {
     return(pageRetriever.Retrieve <Manufacturer>(
                query => query
                .Path(parentAliasPath, PathTypeEnum.Children)
                .OrderBy("NodeOrder"),
                cache => cache
                .Key($"{nameof(KenticoManufacturerRepository)}|{nameof(GetManufacturers)}|{parentAliasPath}")
                // Include path dependency to flush cache when a new child page is created or page order is changed.
                .Dependencies((_, builder) => builder.PagePath(parentAliasPath, PathTypeEnum.Children).PageOrder())));
 }
        //EndDocSection:ForeignPropertyPostModel


        //DocSection:GetManufacturers
        /// <summary>
        /// Loads all available manufacturers assigned to products of the LearningProductType product page type.
        /// </summary>
        /// <returns>List of manufacturers' models and their unselected state.</returns>
        private List <ProductFilterCheckboxViewModel> GetManufacturers()
        {
            // Gets all manufacturers assigned to products of the LearningProductType
            var manufacturers = pageRetriever.Retrieve <LearningProductType>()
                                .ToList()
                                .Where(skuPage => skuPage.Product.Manufacturer != null)
                                .Select(skuPage =>
                                        new
            {
                skuPage.Product.Manufacturer?.ManufacturerID,
                skuPage.Product.Manufacturer?.ManufacturerDisplayName
            })
                                .Distinct();

            // Returns a list of models that contain the manufacturers' display name, ID and false select state
            return(manufacturers.Select(manufacturer => new ProductFilterCheckboxViewModel
            {
                DisplayName = manufacturer.ManufacturerDisplayName,
                Id = manufacturer.ManufacturerID.ToString(),
                IsChecked = false
            }).ToList());
        }
Пример #15
0
        public ActionResult Index()
        {
            // Retrieves the node alias path of the selected page from the 'PagePaths' property
            string selectedPagePath = componentPropertiesRetriever.Retrieve <CustomWidgetProperties>().PagePaths.FirstOrDefault()?.NodeAliasPath;
            // Retrieves the page that corresponds to the selected node alias path
            TreeNode page = pagesRetriever.Retrieve <TreeNode>(query => query
                                                               .Path(selectedPagePath)
                                                               .TopN(1))
                            .FirstOrDefault();

            // Custom logic...

            return(View());
        }
Пример #16
0
        public ActionResult Index()
        {
            // Retrieves the node GUID of the selected page from the 'Pages' property
            Guid?selectedPageGuid = componentPropertiesRetriever.Retrieve <CustomWidgetProperties>().Pages.FirstOrDefault()?.NodeGuid;
            // Retrieves the page that corresponds to the selected GUID
            TreeNode page = pagesRetriever.Retrieve <TreeNode>(query => query
                                                               .WhereEquals("NodeGUID", selectedPageGuid)
                                                               .TopN(1))
                            .FirstOrDefault();

            // Custom logic...

            return(View());
        }
Пример #17
0
 /// <summary>
 /// Returns an enumerable collection of brewers ordered by the date of publication.
 /// </summary>
 /// <param name="filter">Repository filter.</param>
 /// <param name="count">The number of brewers to return. Use 0 as value to return all records.</param>
 public IEnumerable <Brewer> GetBrewers(IRepositoryFilter filter, int count = 0)
 {
     return(pageRetriever.Retrieve <Brewer>(
                query => query
                .TopN(count)
                .WhereTrue("SKUEnabled")
                .Where(filter?.GetWhereCondition())
                .FilterDuplicates()
                .OrderByDescending("SKUInStoreFrom"),
                cache => cache
                .Key($"{nameof(BrewerRepository)}|{nameof(GetBrewers)}|{filter?.GetCacheKey()}|{count}")
                // Include dependency on all pages of this type to flush cache when a new page is created.
                .Dependencies((_, builder) => builder.Pages(Brewer.CLASS_NAME).ObjectType("ecommerce.sku"))));
 }
Пример #18
0
        /// <summary>
        /// Returns the product with the specified identifier.
        /// </summary>
        /// <param name="nodeGUID">The product node identifier.</param>
        /// <returns>The product with the specified node identifier, if found; otherwise, null.</returns>
        public SKUTreeNode GetProduct(Guid nodeGUID)
        {
            return(RepositoryCacheHelper.CachePage(() =>
            {
                var page = pageRetriever.Retrieve <TreeNode>(
                    query => query
                    .WhereEquals("NodeGUID", nodeGUID))
                           .FirstOrDefault();

                if ((page == null) || !page.IsProduct())
                {
                    return null;
                }

                // Load product type specific fields from the database
                page.MakeComplete(true);

                return page as SKUTreeNode;
            }, $"{nameof(KenticoProductRepository)}|{nameof(GetProduct)}|{nodeGUID}", new[]
            {
                CacheDependencyKeyProvider.GetDependencyCacheKeyForObjectType("ecommerce.sku"),
                $"nodeguid|{SiteContext.CurrentSiteName}|{nodeGUID}"
            }));
        }
Пример #19
0
        public IViewComponentResult Invoke(ComponentViewModel <CustomWidgetProperties> properties)
        {
            // Retrieves the node GUIDs of the selected pages from the 'Pages' property
            List <Guid> selectedPageGuids = properties?.Properties?.Pages?
                                            .Select(i => i.NodeGuid)
                                            .ToList();

            // Retrieves the pages that correspond to the selected GUIDs
            List <TreeNode> pages = pagesRetriever.Retrieve <TreeNode>(query => query
                                                                       .WhereIn("NodeGUID", selectedPageGuids))
                                    .ToList();

            // Custom logic...

            return(View("~/Components/Widgets/PageSelectorWidget/_PageSelectorWidget.cshtml"));
        }
Пример #20
0
        public IViewComponentResult Invoke(ComponentViewModel <CustomWidgetProperties> properties)
        {
            // Retrieves the node alias paths of the selected pages from the 'PagePaths' property
            string[] selectedPagePaths = properties?.Properties?.PagePaths?
                                         .Select(i => i.NodeAliasPath)
                                         .ToArray();

            // Retrieves the pages that correspond to the selected alias paths
            List <TreeNode> pages = pagesRetriever.Retrieve <TreeNode>(query => query
                                                                       .Path(selectedPagePaths))
                                    .ToList();

            // Custom logic...

            return(View("~/Components/Widgets/PathSelectorWidget/_PathSelectorWidget.cshtml"));
        }
Пример #21
0
        public ActionResult Index()
        {
            // Retrieves the node GUIDs of the selected pages from the 'Pages' property
            List <Guid> selectedPageGuids = componentPropertiesRetriever.Retrieve <CustomWidgetProperties>().Pages
                                            .Select(i => i.NodeGuid)
                                            .ToList();

            // Retrieves the pages that correspond to the selected GUIDs
            List <TreeNode> pages = pagesRetriever.Retrieve <TreeNode>(query => query
                                                                       .WhereIn("NodeGUID", selectedPageGuids))
                                    .ToList();

            // Custom logic...

            return(View());
        }
Пример #22
0
        public ActionResult Index()
        {
            // Retrieves the node alias paths of the selected pages from the 'PagePaths' property
            string[] selectedPagePaths = componentPropertiesRetriever.Retrieve <CustomWidgetProperties>().PagePaths
                                         .Select(i => i.NodeAliasPath)
                                         .ToArray();

            // Retrieves the pages that correspond to the selected alias paths
            List <TreeNode> pages = pagesRetriever.Retrieve <TreeNode>(query => query
                                                                       .Path(selectedPagePaths))
                                    .ToList();

            // Custom logic...

            return(View());
        }
Пример #23
0
        public ActionResult Home()
        {
            // Retrieves a page from the Xperience database with the '/Home' node alias path
            TreeNode page = pagesRetriever.Retrieve <TreeNode>(query => query
                                                               .Path("/Home", PathTypeEnum.Single))
                            .FirstOrDefault();

            // Responds with the HTTP 404 error when the page is not found
            if (page == null)
            {
                return(NotFound());
            }

            // Initializes the page data context (and the page builder) using the retrieved page
            pageDataContextInitializer.Initialize(page);

            return(View());
        }
        /// <summary>
        /// Returns collection of products categorized under Hot tips page.
        /// </summary>
        /// <param name="parentAliasPath">Parent node alias path.</param>
        public IEnumerable <SKUTreeNode> GetHotTipProducts(string parentAliasPath)
        {
            return(RepositoryCacheHelper.CachePages(() =>
            {
                var hotTipsPage = pageRetriever.Retrieve <HotTips>(
                    query => query
                    .Path($"{parentAliasPath}/Hot-tips", PathTypeEnum.Single)
                    .TopN(1))
                                  .FirstOrDefault();

                return hotTipsPage?.Fields.HotTips
                .OfType <SKUTreeNode>() ?? Enumerable.Empty <SKUTreeNode>();
            }, $"{nameof(KenticoHotTipsRepository)}|{nameof(GetHotTipProducts)}|{parentAliasPath}", new[]
            {
                CacheDependencyKeyProvider.GetDependencyCacheKeyForObjectType("cms.adhocrelationship"),
                CacheDependencyKeyProvider.GetDependencyCacheKeyForObjectType("ecommerce.sku"),
                $"node|{SiteContext.CurrentSiteName}|{parentAliasPath}"
            }));
        }
Пример #25
0
        /// <summary>
        /// A GET action displaying a page where you wish to use page templates.
        /// </summary>
        /// <param name="pageAlias">Page alias of the displayed page.</param>
        public ActionResult Index(string pageAlias)
        {
            // Retrieves a page from the Xperience database
            TreeNode page = pagesRetriever.Retrieve <TreeNode>(query => query
                                                               .Path("/Landing-pages", PathTypeEnum.Children)
                                                               .WhereEquals("NodeAlias", pageAlias)
                                                               .TopN(1))
                            .FirstOrDefault();

            // Responds with the HTTP 404 error when the page is not found
            if (page == null)
            {
                return(NotFound());
            }

            // Returns a TemplateResult object, created with the retrieved page
            // Automatically initializes the page data context and the page builder feature
            // for all editable areas placed within templates
            return(new TemplateResult(page));
        }
Пример #26
0
        /// <summary>
        /// Displays a product listing page of the class's product page type.
        /// </summary>
        public ActionResult Listing()
        {
            // Gets products of the product page type (via the generated page type code)
            List <LearningProductType> products = pageRetriever.Retrieve <LearningProductType>(query => query
                                                                                               .CombineWithDefaultCulture()
                                                                                               .WhereTrue("SKUEnabled")
                                                                                               .OrderByDescending("SKUInStoreFrom"))
                                                  .ToList();

            ShoppingCartInfo cart = shoppingService.GetCurrentShoppingCart();

            // Prepares a collection of products of the LearningProductType page type to be sent to a view
            IEnumerable <ProductListItemViewModel> productListing = products.Select(
                product => new ProductListItemViewModel(
                    product,
                    GetPrice(product.SKU, cart),
                    pageUrlRetriever,
                    product.Product.PublicStatus?.PublicStatusDisplayName));

            // Displays the action's view with an initialized view model
            return(View(productListing));
        }