private ActionResult GetJobProfilesByCategoryView(string urlName)
        {
            var category = categoryRepo.GetByUrlName(urlName);

            //if the category does not exist.
            if (category == null)
            {
                return(HttpNotFound());
            }

            var jobProfiles = categoryRepo.GetRelatedJobProfiles(category.Title);
            var description = Regex.Replace(MetaDescription, @"{jobcategory}", m => category.Title, RegexOptions.IgnoreCase);

            webAppContext.SetMetaDescription(description);

            var model = new JobProfileByCategoryViewModel
            {
                Title         = category.Title,
                Description   = category.Description,
                JobProfiles   = jobProfiles,
                JobProfileUrl = JobProfileDetailsPage,
            };

            return(View("Index", model));
        }
        /// <summary>
        /// Gets the job profile details view.
        /// </summary>
        /// <param name="urlName">The urlname.</param>
        /// <returns>ActionResult</returns>
        private ActionResult GetBreadcrumbView(string urlName)
        {
            var breadCrumbLink = new BreadcrumbLink();
            var model          = new DfcBreadcrumbViewModel
            {
                HomepageText    = HomepageText,
                HomepageLink    = HomepageLink,
                BreadcrumbLinks = new List <BreadcrumbLink>
                {
                    breadCrumbLink
                }
            };

            // We get the page node we are on
            var currentPageNode = sitefinityCurrentContext.GetCurrentDfcPageNode();

            if (currentPageNode != null)
            {
                var nodeUrl = currentPageNode.Url.OriginalString;
                switch (nodeUrl.ToUpperInvariant())
                {
                case var jobCategoriesPage when !string.IsNullOrEmpty(urlName) && jobCategoriesPage.Contains(JobCategoriesPathSegment):
                {
                    var category = categoryRepo.GetByUrlName(urlName);
                    breadCrumbLink.Text = (category == null) ? currentPageNode.Title : category.Title;
                    break;
                }

                case var jobProfilePage when !string.IsNullOrEmpty(urlName) && jobProfilePage.Contains(JobProfilesPathSegment):
                {
                    var jobProfile = jobProfileRepository.GetByUrlName(urlName);
                    breadCrumbLink.Text = (jobProfile == null) ? currentPageNode.Title : jobProfile.Title;
                    break;
                }

                case var alertsPage when alertsPage.Contains(AlertsPathSegment):
                {
                    breadCrumbLink.Text = AlertsPageText;
                    break;
                }

                default:
                {
                    model.BreadcrumbLinks = sitefinityCurrentContext.BreadcrumbToParent();

                    //the current page should not be linked
                    model.BreadcrumbLinks.FirstOrDefault().Link = null;
                    model.BreadcrumbLinks = model.BreadcrumbLinks.Reverse().ToList();
                    break;
                }
                }
            }

            return(View(model));
        }
Ejemplo n.º 3
0
        public void IndexCustomPagesTest(SegmentType segmentType, string repoTitle, string expectedLinkTitle)
        {
            //Setup
            var dummyDfcPageSiteNode = A.Dummy <DfcPageSiteNode>();

            dummyDfcPageSiteNode.Title = expectedLinkTitle;
            A.CallTo(() => sitefinityCurrentContext.GetCurrentDfcPageNode()).Returns(dummyDfcPageSiteNode);

            //Instantiate
            var dfcBreadcrumbController = new DfcBreadcrumbController(repositoryCategoryFake, repositoryJobProfileFake, sitefinityCurrentContext, loggerFake);

            switch (segmentType)
            {
            case SegmentType.Category:
                dummyDfcPageSiteNode.Url = new Uri($"/abcd/{dfcBreadcrumbController.JobCategoriesPathSegment}", UriKind.RelativeOrAbsolute);
                A.CallTo(() => repositoryCategoryFake.GetByUrlName(A <string> ._)).Returns(repoTitle == null ? null : new JobProfileCategory()
                {
                    Title = repoTitle
                });
                break;

            case SegmentType.JobProfile:
                dummyDfcPageSiteNode.Url = new Uri($"/abcd/{dfcBreadcrumbController.JobProfilesPathSegment}", UriKind.RelativeOrAbsolute);
                A.CallTo(() => repositoryJobProfileFake.GetByUrlName(A <string> ._)).Returns(repoTitle == null ? null : new JobProfile()
                {
                    Title = repoTitle
                });
                break;

            case SegmentType.Alert:
                dummyDfcPageSiteNode.Url = new Uri($"/abcd/{dfcBreadcrumbController.AlertsPathSegment}", UriKind.RelativeOrAbsolute);
                dfcBreadcrumbController.AlertsPageText = expectedLinkTitle;
                break;
            }

            // Act
            var indexMethodCall = dfcBreadcrumbController.WithCallTo(c => c.Index("dummyURLName"));

            //Assert
            indexMethodCall
            .ShouldRenderDefaultView()
            .WithModel <DfcBreadcrumbViewModel>(vm =>
            {
                vm.HomepageText.Should().BeEquivalentTo(dfcBreadcrumbController.HomepageText);
                vm.HomepageLink.Should().BeEquivalentTo(dfcBreadcrumbController.HomepageLink);
                vm.BreadcrumbLinks.FirstOrDefault().Text.Should().BeEquivalentTo(expectedLinkTitle);
                vm.BreadcrumbLinks.FirstOrDefault().Link.Should().BeEquivalentTo(null);
            })
            .AndNoModelErrors();
        }
Ejemplo n.º 4
0
        public ActionResult Index(string urlName)
        {
            if (webAppContext.IsCategoryPage && !string.IsNullOrEmpty(urlName))
            {
                var category = categoryRepo.GetByUrlName(urlName);
                if (category != null)
                {
                    this.ViewBag.Title = $"{category.Title} {PageTitleSeparator} {PageTitleSuffix}";
                }
            }
            else if (webAppContext.IsJobProfilePage && !string.IsNullOrEmpty(urlName))
            {
                var jobProfile = jobProfileRepository.GetByUrlName(urlName);
                if (jobProfile != null)
                {
                    this.ViewBag.Title = $"{jobProfile.Title} {PageTitleSeparator} {PageTitleSuffix}";
                }
            }

            //Need to return a blank view so that we can check the view bag in tests.
            return(View(new SetContentRelatedPageTitleModel {
                DisplayView = webAppContext.IsContentAuthoringAndNotPreviewMode
            }));
        }