Example #1
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());
        }
Example #2
0
        public async Task <IActionResult> Index(CancellationToken cancellationToken)
        {
            if (_pageDataContextRetriever.TryRetrieve <CMS.DocumentEngine.Types.MedioClinic.NamePerexText>(out var pageDataContext) &&
                pageDataContext.Page != null)
            {
                var contactPath = pageDataContext.Page.NodeAliasPath;
                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(data, title: contactPage.Name !);

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

            return(NotFound());
        }
        public async Task <IActionResult> Index(CancellationToken cancellationToken)
        {
            var company = (await _companyRepository.GetPagesInCurrentCultureAsync(
                               cancellationToken,
                               filter => filter
                               .Path("/Contact-us/Medio-Clinic", PathTypeEnum.Single)
                               .TopN(1),
                               buildCacheAction: cache => cache
                               .Key($"{nameof(ContactController)}|Company")
                               .Dependencies((_, builder) => builder
                                             .PageType(CMS.DocumentEngine.Types.MedioClinic.Company.CLASS_NAME))))
                          .FirstOrDefault();

            var officeLocations = (await _mapLocationRepository.GetPagesInCurrentCultureAsync(
                                       cancellationToken,
                                       filter => filter
                                       .Path("/Contact-us/Office-locations", PathTypeEnum.Children),
                                       buildCacheAction: cache => cache
                                       .Key($"{nameof(ContactController)}|OfficeLocations")
                                       .Dependencies((_, builder) => builder
                                                     .PageType(CMS.DocumentEngine.Types.MedioClinic.MapLocation.CLASS_NAME))));

            var contactPage = (await _namePerexTextRepository.GetPagesInCurrentCultureAsync(
                                   cancellationToken,
                                   filter => filter
                                   .Path("/Contact-us", PathTypeEnum.Single)
                                   .TopN(1),
                                   buildCacheAction: cache => cache
                                   .Key($"{nameof(ContactController)}|ContactPage")
                                   .Dependencies((_, builder) => builder
                                                 .PageType(CMS.DocumentEngine.Types.MedioClinic.NamePerexText.CLASS_NAME)),
                                   includeAttachments: true))
                              .FirstOrDefault();

            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(data, title: contactPage.Name !);

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

            return(NotFound());
        }