public async Task <IActionResult> Index(CancellationToken cancellationToken)
        {
            var page = (await _pageRetriever.RetrieveAsync <CMS.DocumentEngine.Types.MedioClinic.Doctor>(
                            filter => filter
                            .Path(DoctorsPath, PathTypeEnum.Single)
                            .TopN(1),
                            cache => cache
                            .Key($"{nameof(DoctorsController)}|DoctorSection")
                            .Dependencies((_, builder) => builder
                                          .PageType(CMS.DocumentEngine.Types.MedioClinic.SiteSection.CLASS_NAME))))
                       .FirstOrDefault();

            var metadata = _metadataRetriever.Retrieve(page);

            var doctorPages = await _doctorRepository.GetPagesInCurrentCultureAsync(
                cancellationToken,
                filter => filter
                .Path(DoctorsPath, PathTypeEnum.Children),
                buildCacheAction : cache => cache
                .Key($"{nameof(DoctorsController)}|Doctors")
                .Dependencies((_, builder) => builder
                              .PageType(CMS.DocumentEngine.Types.MedioClinic.Doctor.CLASS_NAME)
                              .PageOrder()));

            if (doctorPages?.Any() == true)
            {
                var data      = (page.DocumentName, doctorPages);
                var viewModel = GetPageViewModel(metadata, data);

                return(View("Doctors/Index", viewModel));
            }

            return(NotFound());
        }
Example #2
0
        public async Task <IActionResult> Index(CancellationToken cancellationToken)
        {
            var page = (await _pageRetriever.RetrieveAsync <CMS.DocumentEngine.Types.MedioClinic.NamePerexText>(
                            filter => filter
                            .Path(ContactPath, PathTypeEnum.Single)
                            .TopN(1),
                            cache => cache
                            .Key($"{nameof(ContactController)}|ContactPage")
                            .Dependencies((_, builder) => builder
                                          .PageType(CMS.DocumentEngine.Types.MedioClinic.NamePerexText.CLASS_NAME))))
                       .FirstOrDefault();

            var metadata = _metadataRetriever.Retrieve(page);

            var(company, officeLocations, contactPage) = await GetPageData(ContactPath, cancellationToken);

            var medicalServicePictures = await _mediaFileRepository.GetMediaFilesAsync("CommonImages", "MedicalServices");

            if (company != null && officeLocations?.Any() == true && contactPage != null && medicalServicePictures?.Any() == true)
            {
                var data = new ContactViewModel
                {
                    Company         = company,
                    ContactPage     = contactPage,
                    MedicalServices = medicalServicePictures,
                    OfficeLocations = officeLocations
                };

                var viewModel = GetPageViewModel(metadata, data);

                return(View("Contact/Index", viewModel));
            }

            return(NotFound());
        }
 /// <summary>
 /// Asynchronously 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>
 /// <param name="cancellationToken">The cancellation instruction.</param>
 public Task <IEnumerable <AboutUsSection> > GetSideStoriesAsync(string nodeAliasPath, CancellationToken cancellationToken)
 {
     return(pageRetriever.RetrieveAsync <AboutUsSection>(
                query => query
                .Path(nodeAliasPath, PathTypeEnum.Children)
                .OrderBy("NodeOrder"),
                cache => cache
                .Key($"{nameof(KenticoAboutUsRepository)}|{nameof(GetSideStoriesAsync)}|{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()),
                cancellationToken));
 }
Example #4
0
 /// <summary>
 /// Asynchronously returns an enumerable collection of references ordered by the node order.
 /// </summary>
 /// <param name="nodeAliasPath">The node alias path of the parent page in the content tree.</param>
 /// <param name="cancellationToken">The cancellation instruction.</param>
 /// <param name="count">The number of references to return. Use 0 as value to return all records.</param>
 public Task <IEnumerable <Reference> > GetReferencesAsync(string nodeAliasPath, CancellationToken cancellationToken, int count = 0)
 {
     return(pageRetriever.RetrieveAsync <Reference>(
                query => query
                .Path(nodeAliasPath, PathTypeEnum.Children)
                .TopN(count)
                .OrderBy("NodeOrder"),
                cache => cache
                .Key($"{nameof(ReferenceRepository)}|{nameof(GetReferencesAsync)}|{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()),
                cancellationToken));
 }
        public async Task <IActionResult> Index(CancellationToken cancellationToken)
        {
            var homePath = "/Home";

            var page = (await _pageRetriever.RetrieveAsync <CMS.DocumentEngine.Types.MedioClinic.Doctor>(
                            filter => filter
                            .Path(homePath, PathTypeEnum.Single)
                            .TopN(1),
                            cache => cache
                            .Key($"{nameof(HomeController)}|HomePage")
                            .Dependencies((_, builder) => builder
                                          .PageType(CMS.DocumentEngine.Types.MedioClinic.HomePage.CLASS_NAME))))
                       .FirstOrDefault();

            var metadata = _metadataRetriever.Retrieve(page);

            var homePage = (await _homePageRepository.GetPagesInCurrentCultureAsync(
                                cancellationToken,
                                filter => filter
                                .Path(homePath, PathTypeEnum.Single)
                                .TopN(1),
                                buildCacheAction: cache => cache
                                .Key($"{nameof(HomeController)}|HomePage")
                                .Dependencies((_, builder) => builder
                                              .PageType(CMS.DocumentEngine.Types.MedioClinic.HomePage.CLASS_NAME)),
                                includeAttachments: true))
                           .FirstOrDefault();

            var companyServices = await _companyServiceRepository.GetPagesInCurrentCultureAsync(
                cancellationToken,
                filter => filter
                .Path(homePath, PathTypeEnum.Children),
                buildCacheAction : cache => cache
                .Key($"{nameof(HomeController)}|CompanyServices")
                .Dependencies((_, builder) => builder
                              .PageType(CMS.DocumentEngine.Types.MedioClinic.CompanyService.CLASS_NAME)
                              .PagePath(homePath, PathTypeEnum.Children)
                              .PageOrder()));

            if (homePage != null && companyServices?.Any() == true)
            {
                var data      = (homePage, companyServices);
                var viewModel = GetPageViewModel <(HomePage, IEnumerable <CompanyService>)>(metadata, data);

                return(View("Home/Index", viewModel));
            }

            return(NotFound());
        }
Example #6
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            // Retrieves a collection of page objects with data for the menu (pages of all page types)
            IEnumerable <TreeNode> menuItems = await pageRetriever.RetrieveAsync <TreeNode>(query => query
                                                                                            // Selects pages that have the 'Show in menu" flag enabled
                                                                                            .MenuItems()
                                                                                            // Only loads pages from the first level of the site's content tree
                                                                                            .NestingLevel(1)
                                                                                            // Filters the query to only retrieve required columns
                                                                                            .Columns("DocumentName", "NodeID", "NodeSiteID")
                                                                                            // Uses the menu item order from the content tree
                                                                                            .OrderByAscending("NodeOrder"));

            // Creates a collection of view models based on the menu item data
            List <MenuItemViewModel> model = menuItems.Select(item => new MenuItemViewModel()
            {
                // Gets the name of the page as the menu item caption text
                MenuItemText = item.DocumentName,
                // Retrieves the URL for the page (as a relative virtual path)
                MenuItemRelativeUrl = urlRetriever.Retrieve(item).RelativePath,
                // Check if this is the current page
                IsCurrentPage = item.NodeAliasPath.ToLower().Equals(Request.Path.Value)
            }).ToList();

            //manually inject the manage page
            model.Add(new MenuItemViewModel()
            {
                MenuItemText        = "Manage",
                MenuItemRelativeUrl = "~/SafetyDiscussion",
                IsCurrentPage       = Request.Path.Value.ToLower().Contains("safetydiscussion")
            });

            //manually inject admin link
            model.Add(new MenuItemViewModel()
            {
                MenuItemText        = "Admin",
                MenuItemRelativeUrl = "~/admin",
                IsCurrentPage       = false
            });

            return(View(model));
        }