public ActionResult Index() { var model = new UserListViewModel() { CurrentOrganization = CurrentOrganization, CurrentUser = CurrentUser }; using (var ctx = new CoronaSupportPlatformDbContext()) { // Load the roles var roles = ctx.Roles.ToList(); // Load the users var users = ctx.Users.Include("Roles.Organization").ToList(); // Convert model.Users = users.Select(u => new UserViewModel().From(u, roles)).ToList(); } #region [ Breadcrumb ] var breadcrumb = new BreadcrumbViewModel(); breadcrumb.PageName = "Kullanıcı Listesi"; breadcrumb.Items.Add("Anasayfa", "/"); breadcrumb.Items.Add("Kullanıcı Listesi", ""); TempData["Breadcrumb"] = breadcrumb; #endregion return(View(model)); }
private static BreadcrumbViewModel getHomeBreadcrumb(UrlHelper urlHelper) { BreadcrumbViewModel breadcrumb = new BreadcrumbViewModel(); breadcrumb.AddItem("Home", urlHelper.Action("Index", "Home")); return(breadcrumb); }
public static BreadcrumbViewModel GetProductsBreadcrumb(UrlHelper urlHelper) { BreadcrumbViewModel breadcrumb = getHomeBreadcrumb(urlHelper); breadcrumb.AddItem("Products", urlHelper.Action("Index", "Products")); return(breadcrumb); }
public ActionResult Details(int id) { var model = new UserViewModel() { CurrentOrganization = CurrentOrganization, CurrentUser = CurrentUser }; using (var ctx = new CoronaSupportPlatformDbContext()) { // Load the roles var roles = ctx.Roles.ToList(); // Load the user var user = ctx.Users.Include("Roles.Organization").FirstOrDefault(u => u.Id == id); // Convert model = model.From(user, roles); } #region [ Breadcrumb ] var breadcrumb = new BreadcrumbViewModel(); breadcrumb.PageName = "Kullanıcı Detay"; breadcrumb.Items.Add("Anasayfa", "/"); breadcrumb.Items.Add("Kullanıcı Listesi", "/Users"); breadcrumb.Items.Add(model.Firstname + " " + model.Lastname, ""); TempData["Breadcrumb"] = breadcrumb; #endregion return(View(model)); }
private static BreadcrumbViewModel BuildBreadcrumb(JobProfileModel jobProfileModel) { var viewModel = new BreadcrumbViewModel { Paths = new List <BreadcrumbPathViewModel>() { new BreadcrumbPathViewModel() { Route = "/", Title = "Home", }, new BreadcrumbPathViewModel { Route = $"/{ProfilePathRoot}", Title = "Job Profiles", }, }, }; if (jobProfileModel != null) { var breadcrumbPathViewModel = new BreadcrumbPathViewModel { Route = $"/{ProfilePathRoot}/{jobProfileModel.CanonicalName}", Title = jobProfileModel.BreadcrumbTitle, }; viewModel.Paths.Add(breadcrumbPathViewModel); } viewModel.Paths.Last().AddHyperlink = false; return(viewModel); }
private static BreadcrumbViewModel BuildBreadcrumb(JobProfileOverviewSegmentModel model, string routePrefix) { var viewModel = new BreadcrumbViewModel { Paths = new List <BreadcrumbPathViewModel>() { new BreadcrumbPathViewModel() { Route = $"/explore-careers", Title = "Home: Explore careers", }, }, }; if (model != null) { var breadcrumbPathViewModel = new BreadcrumbPathViewModel { Route = $"/{routePrefix}/{model.CanonicalName}", Title = model.Data.Title, }; viewModel.Paths.Add(breadcrumbPathViewModel); } viewModel.Paths.Last().AddHyperlink = false; return(viewModel); }
public static BreadcrumbViewModel GetCategoryBreadcrumb(UrlHelper urlHelper, string categoryTitle, string categoryName) { BreadcrumbViewModel breadcrumb = GetProductsBreadcrumb(urlHelper); breadcrumb.AddItem(categoryTitle, urlHelper.Action("Index", "Category", new { categoryName = categoryName })); return(breadcrumb); }
public static BreadcrumbViewModel GetWhereToBuyBreadcrumb(UrlHelper urlHelper, string mainHeading) { BreadcrumbViewModel breadcrumb = getHomeBreadcrumb(urlHelper); breadcrumb.AddItem(mainHeading, urlHelper.Action("Index", "WhereToBuy")); return(breadcrumb); }
private static BreadcrumbViewModel BuildBreadcrumb(JobCategory?jobCategoryModel) { var viewModel = new BreadcrumbViewModel { Paths = new List <BreadcrumbPathViewModel>() { new BreadcrumbPathViewModel() { Route = "/explore-careers", Title = "Home: Explore careers", }, }, }; if (jobCategoryModel != null) { if (!string.IsNullOrWhiteSpace(jobCategoryModel.CanonicalName)) { var jobCategoryPathViewModel = new BreadcrumbPathViewModel { Route = $"/{jobCategoryModel.CanonicalName}", Title = $"{jobCategoryModel.Title}", }; viewModel.Paths.Add(jobCategoryPathViewModel); } viewModel.Paths.Last().AddHyperlink = false; } return(viewModel); }
public ActionResult Index() { // Create the model var model = new TenderListViewModel(); using (var ctx = new CoronaSupportPlatformDbContext()) { if (User.IsInRole("Administrator")) { // Load all tenders if administrator var tenders = ctx.Tenders.Include("Organization").Include("Items.Product").Include("Properties").Include("Tags").ToList(); model.Tenders = tenders.Select(t => new TenderViewModel().From(t)).ToList(); } else { // Load only the tenders for the current user var tenders = ctx.Tenders.Include("Organization").Include("Items.Product").Include("Properties").Include("Items").Where(u => u.UserId == CurrentUser.Id).ToList(); model.Tenders = tenders.Select(t => new TenderViewModel().From(t)).ToList(); } } #region [ Breadcrumb ] var breadcrumb = new BreadcrumbViewModel(); breadcrumb.PageName = "İhtiyaç Listesi"; breadcrumb.Items.Add("Anasayfa", "/"); breadcrumb.Items.Add("İhtiyaç Listesi", ""); TempData["Breadcrumb"] = breadcrumb; #endregion return(View(model)); }
public static BreadcrumbViewModel GetProductBreadcrumb( UrlHelper urlHelper, string categoryTitle, string categoryName, string productTitle, string productName ) { BreadcrumbViewModel breadcrumb = GetCategoryBreadcrumb(urlHelper, categoryTitle, categoryName); breadcrumb.AddItem(productTitle, urlHelper.Action("Index", "Product", new { productName = productName })); return(breadcrumb); }
public ActionResult Breadcrumb(List <Erp.BackOffice.Areas.Administration.Models.PageMenuViewModel> DataMenuItem, string controllerName, string actionName, string areaName) { var model = new List <BreadcrumbViewModel>(); var currentUrl = ("/" + controllerName + "/" + actionName).ToLower(); var pageMenuItem = DataMenuItem.Where(x => (x.Url != null && x.Url.ToLower() == currentUrl) || (x.PageUrl != null && x.PageUrl.ToLower() == currentUrl)).FirstOrDefault(); if (pageMenuItem == null) { currentUrl = ("/" + controllerName + "/index").ToLower(); pageMenuItem = DataMenuItem.Where(x => x.PageUrl != null && x.PageUrl.ToLower() == currentUrl).FirstOrDefault(); } while (pageMenuItem != null) { var breadCrumb = new BreadcrumbViewModel { Area = pageMenuItem.AreaName, ParrentId = pageMenuItem.ParentId, Name = pageMenuItem.Name, Url = pageMenuItem.PageUrl }; model.Insert(0, breadCrumb); if (pageMenuItem.ParentId != null) { pageMenuItem = DataMenuItem.Where(x => x.Id == pageMenuItem.ParentId.Value).FirstOrDefault(); } else { pageMenuItem = null; } } return(PartialView("_BreadcrumbPartial", model)); //var page = _pageMenuRepository.GetPageByAction(areaName, controllerName, actionName); //if (page != null) //{ // var model = new BreadcrumbViewModel // { // Area = page.AreaName, // Controller = page.ControllerName, // Action = page.ActionName, // ParrentId = page.ParentId, // Name = _pageMenuRepository.GetPageName(page.Id, Session["CurrentLanguage"].ToString()), // Url = page.Url // }; // return PartialView("_BreadcrumbPartial", model); //} //return PartialView("_BreadcrumbPartial", null); }
public async Task <ProductBreadcrumbsViewModel> BuildModelAsync(ComponentModelBase componentModel) { var viewModel = this.breadcrumbsModelBuilder.BuildModel(componentModel); var product = await this.productsRepository.GetProductAsync(componentModel.Id, componentModel.Language, componentModel.Token); if (product != null) { var categoryBreadcrumb = new BreadcrumbViewModel { Name = product.CategoryName, Url = this.linkGenerator.GetPathByAction("Index", "Category", new { Area = "Products", culture = CultureInfo.CurrentUICulture.Name, Id = product.CategoryId }), IsActive = false }; viewModel.Items.Add(categoryBreadcrumb); if (product.PrimaryProductId.HasValue) { var primaryProduct = await this.productsRepository.GetProductAsync(product.PrimaryProductId.Value, componentModel.Language, componentModel.Token); if (primaryProduct != null) { var primaryProductBreadcrumb = new BreadcrumbViewModel { Name = primaryProduct.Name, Url = this.linkGenerator.GetPathByAction("Index", "Product", new { Area = "Products", culture = CultureInfo.CurrentUICulture.Name, primaryProduct.Id }), IsActive = false }; var secondaryProductBreadcrumb = new BreadcrumbViewModel { Name = $"{product.Name} ({product.Sku})", Url = this.linkGenerator.GetPathByAction("Index", "Product", new { Area = "Products", culture = CultureInfo.CurrentUICulture.Name, product.Id }), IsActive = true }; viewModel.Items.Add(primaryProductBreadcrumb); viewModel.Items.Add(secondaryProductBreadcrumb); } } else { var productBreadcrumb = new BreadcrumbViewModel { Name = product.Name, Url = this.linkGenerator.GetPathByAction("Index", "Product", new { Area = "Products", culture = CultureInfo.CurrentUICulture.Name, product.Id }), IsActive = true }; viewModel.Items.Add(productBreadcrumb); } } return(viewModel); }
public async Task <IViewComponentResult> InvokeAsync() { var breadcrumbModel = new BreadcrumbViewModel { Controller = ViewContext.RouteData.Values["controller"].ToString(), Action = ViewBag.Action = ViewContext.RouteData.Values["action"].ToString() }; return(await Task.FromResult(View("~/Views/Shared/Components/_Breadcrumb.cshtml", breadcrumbModel))); }
public async Task PagesControllerBreadcrumbJsonReturnsSuccess(string mediaTypeName) { // Arrange var socRequestModel = new SocRequestModel { Soc = 3231, FromJobProfileCanonicalName = "a-job-profile", }; var dummyJobGroupModel = A.Dummy <JobGroupModel>(); dummyJobGroupModel.JobProfiles = new List <JobProfileModel> { new JobProfileModel { CanonicalName = socRequestModel.FromJobProfileCanonicalName, Title = "A title" }, }; var controller = BuildPagesController(mediaTypeName); var breadcrumbViewModel = new BreadcrumbViewModel { Breadcrumbs = new List <BreadcrumbItemViewModel> { new BreadcrumbItemViewModel { Title = "Home: Explore careers", Route = "/", }, new BreadcrumbItemViewModel { Title = dummyJobGroupModel.JobProfiles.First().Title, Route = $"/job-profiles/" + dummyJobGroupModel.JobProfiles.First().CanonicalName, }, new BreadcrumbItemViewModel { Title = "Job group LMI", Route = $"/{PagesController.RegistrationPath}", AddHyperlink = false, }, }, }; A.CallTo(() => FakeJobGroupDocumentService.GetAsync(A <Expression <Func <JobGroupModel, bool> > > .Ignored, A <string> .Ignored)).Returns(dummyJobGroupModel); // Act var result = await controller.Breadcrumb(socRequestModel).ConfigureAwait(false); // Assert A.CallTo(() => FakeJobGroupDocumentService.GetAsync(A <Expression <Func <JobGroupModel, bool> > > .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly(); var jsonResult = Assert.IsType <OkObjectResult>(result); Assert.IsAssignableFrom <BreadcrumbViewModel>(jsonResult.Value); var viewModel = jsonResult.Value as BreadcrumbViewModel; Assert.Equal(breadcrumbViewModel.Breadcrumbs[1].Title, viewModel?.Breadcrumbs?[1].Title); Assert.Equal(breadcrumbViewModel.Breadcrumbs[1].Route, viewModel?.Breadcrumbs?[1].Route); controller.Dispose(); }
public ActionResult Detail(string pageTitle = null, IEnumerable <PathInfoViewModel> pathInfo = null) { var breadcrumbViewModel = new BreadcrumbViewModel( pageTitle: String.IsNullOrEmpty(pageTitle) ? String.Empty : pageTitle, pathInfos: pathInfo ?? Enumerable.Empty <PathInfoViewModel>(), breadcrumbSeparator: "/"); return(PartialView(ViewNames.DetailPartial, breadcrumbViewModel)); }
public ActionResult Rendering() { BreadcrumbWrapper breadcrumbs = new BreadcrumbWrapper(); IList <Item> items = GetBreadcrumbItems(); foreach (Item item in items) { if (!IsTemplateBlacklisted(item.TemplateName)) { BreadcrumbViewModel crumb = new BreadcrumbViewModel(item); crumb.BreadcrumbName = item["Name"]; crumb.IsActive = Sitecore.Context.Item.ID == item.ID; crumb.BreadcrumbUrl = LinkManager.GetItemUrl(item); breadcrumbs.SitecoreBreadcrumbs.Add(crumb); } } var product = _catalogContext.CurrentProduct; var lastCategory = _catalogContext.CurrentCategory; foreach (var category in _catalogContext.CurrentCategories) { BreadcrumbViewModelUcommerce crumb = new BreadcrumbViewModelUcommerce { BreadcrumbNameUcommerce = category.DisplayName, BreadcrumbUrlUcommerce = _urlService.GetUrl(_catalogContext.CurrentCatalog, new [] { category }.Compact().ToArray()) }; lastCategory = category; breadcrumbs.UcommerceBreadcrumbs.Add(crumb); } if (product != null) { var breadcrumb = new BreadcrumbViewModelUcommerce { BreadcrumbNameUcommerce = product.DisplayName, BreadcrumbUrlUcommerce = _urlService.GetUrl(_catalogContext.CurrentCatalog, new [] { lastCategory }.Compact().ToArray(), product) }; breadcrumbs.UcommerceBreadcrumbs.Add(breadcrumb); } if (IsTemplateWhitelisted(Sitecore.Context.Item.TemplateName)) { BreadcrumbViewModelUcommerce currentCrumb = new BreadcrumbViewModelUcommerce(); currentCrumb.BreadcrumbNameUcommerce = Sitecore.Context.Item.DisplayName; currentCrumb.BreadcrumbUrlUcommerce = LinkManager.GetItemUrl(Sitecore.Context.Item); breadcrumbs.UcommerceBreadcrumbs.Add(currentCrumb); } return(View(breadcrumbs)); }
void IActionFilter.OnActionExecuting(ActionExecutingContext context) { if (context.Controller is Controller controller) { AdobeAnalyticsViewModel AdobeAnalyticsData = new AdobeAnalyticsViewModel(context.HttpContext, _appSetting); BreadcrumbViewModel BreadcrumbData = new BreadcrumbViewModel(new List <BreadcrumbLink>()); controller.ViewBag.CookieScriptUrl = _appSetting.CookieScriptUrl; controller.ViewBag.AdobeAnalytics = AdobeAnalyticsData; controller.ViewBag.Breadcrumbs = BreadcrumbData; } }
public ActionResult Rendering() { BreadcrumbWrapper breadcrumbs = new BreadcrumbWrapper(); IList <Item> items = GetBreadcrumbItems(); foreach (Item item in items) { if (!IsTemplateBlacklisted(item.TemplateName)) { BreadcrumbViewModel crumb = new BreadcrumbViewModel(item); crumb.BreadcrumbName = item["Name"]; crumb.IsActive = Sitecore.Context.Item.ID == item.ID; crumb.BreadcrumbUrl = LinkManager.GetItemUrl(item); breadcrumbs.SitecoreBreadcrumbs.Add(crumb); } } Product product = SiteContext.Current.CatalogContext.CurrentProduct; Category lastCategory = SiteContext.Current.CatalogContext.CurrentCategory; foreach (var category in SiteContext.Current.CatalogContext.CurrentCategories) { BreadcrumbViewModelUcommerce crumb = new BreadcrumbViewModelUcommerce() { BreadcrumbNameUcommerce = category.DisplayName(), BreadcrumbUrlUcommerce = CatalogLibrary.GetNiceUrlForCategory(category) }; lastCategory = category; breadcrumbs.UcommerceBreadcrumbs.Add(crumb); } if (product != null) { var breadcrumb = new BreadcrumbViewModelUcommerce() { BreadcrumbNameUcommerce = product.DisplayName(), BreadcrumbUrlUcommerce = CatalogLibrary.GetNiceUrlForProduct(product, lastCategory) }; breadcrumbs.UcommerceBreadcrumbs.Add(breadcrumb); } if (IsTemplateWhitelisted(Sitecore.Context.Item.TemplateName)) { BreadcrumbViewModelUcommerce currentCrumb = new BreadcrumbViewModelUcommerce(); currentCrumb.BreadcrumbNameUcommerce = Sitecore.Context.Item.DisplayName; currentCrumb.BreadcrumbUrlUcommerce = LinkManager.GetItemUrl(Sitecore.Context.Item); breadcrumbs.UcommerceBreadcrumbs.Add(currentCrumb); } return(View(breadcrumbs)); }
public PartialViewResult GetCategoryBreadcrumb(Category category) { using (UnitOfWorkManager.NewUnitOfWork()) { var viewModel = new BreadcrumbViewModel { Categories = _categoryService.GetCategoryParents(category).ToList(), Category = category }; return(PartialView("GetCategoryBreadcrumb", viewModel)); } }
public ActionResult Manage(BreadcrumbViewModel breadcrumbViewModel) { // Now, create all new Sections and Items, providing the Agenda Id for Referential Integrity IList <Category> categories = JsonConvert.DeserializeObject <IList <Category> >(breadcrumbViewModel.CategoriesJson); ProcessCategories(breadcrumbViewModel.WebsiteId, categories); db.SaveChanges(); TempData["successMessage"] = "Breadcrumb Categories Saved"; return(RedirectToAction("Manage", new { websiteId = breadcrumbViewModel.WebsiteId })); }
/// <summary> /// Creates a breadcrumb viewmodel based on the http context /// </summary> /// <param name="context">current http context </param> /// <returns>view model</returns> public BreadcrumbViewModel CreateViewModel(HttpContext context) { var vm = new BreadcrumbViewModel { Text = this.Text, UriFragment = $"/{this.Controller}/{this.Action}/", }; this.OnConfigureViewModel(vm, context); return(vm); }
public virtual PartialViewResult GetGroupBreadcrumb(Group group) { var loggedOnUsersRole = GetGroupMembershipRole(group.Id); var allowedGroups = _groupService.GetAllowedGroups(loggedOnUsersRole, LoggedOnReadOnlyUser?.Id); var viewModel = new BreadcrumbViewModel { Groups = _groupService.GetGroupParents(group, allowedGroups), Group = group }; return(PartialView("GetGroupBreadcrumb", viewModel)); }
public PartialViewResult GetCategoryBreadcrumb(Category category) { var loggedOnReadOnlyUser = User.GetMembershipUser(MembershipService); var loggedOnUsersRole = loggedOnReadOnlyUser.GetRole(RoleService); var allowedCategories = _categoryService.GetAllowedCategories(loggedOnUsersRole); var viewModel = new BreadcrumbViewModel { Categories = _categoryService.GetCategoryParents(category, allowedCategories), Category = category }; return(PartialView("GetCategoryBreadcrumb", viewModel)); }
public void Breadcrumb_ViewModel_Test() { List <BreadcrumbLink> links = new List <BreadcrumbLink> { new BreadcrumbLink("www.testurl1.com", "Test Url 1"), new BreadcrumbLink("www.testurl2.com", "Test Url 2") }; BreadcrumbViewModel breadcrumb = new BreadcrumbViewModel(links); Assert.IsInstanceOf <IEnumerable <BreadcrumbLink> >(breadcrumb.Links); Assert.AreEqual(breadcrumb.Links.Count(), 3); Assert.AreEqual(breadcrumb.BackLink, links.LastOrDefault()); }
/// <summary> /// Class constructor. /// </summary> public BreadCrumbControllerViewModel() { _Semaphore = new SemaphoreSlim(1, 1); _OneTaskScheduler = new OneTaskLimitedScheduler(); _CancelTokenSource = new CancellationTokenSource(); TaskQueue = new BrowseRequestTaskQueueViewModel(); // Initialize Breadcrumb Tree ViewModel and SpecialFolders Test ViewModel BreadcrumbBrowser = new BreadcrumbViewModel(this as INavigationController); WeakEventManager <ICanNavigate, BrowsingEventArgs> .AddHandler(BreadcrumbBrowser, "BrowseEvent", Control_BrowseEvent); }
public PartialViewResult GetCategoryBreadcrumb(Category category) { var allowedCategories = _categoryService.GetAllowedCategories(UsersRole); using (UnitOfWorkManager.NewUnitOfWork()) { var viewModel = new BreadcrumbViewModel { Categories = _categoryService.GetCategoryParents(category, allowedCategories), Category = category }; return(PartialView("GetCategoryBreadcrumb", viewModel)); } }
public async Task PagesControllerDocumentJsonReturnsSuccess(string mediaTypeName) { // Arrange var pageRequestModel = new PageRequestModel { Location1 = "a-location-name", Location2 = "an-article-name", }; var expectedResult = new ContentPageModel() { PageLocation = "/" + pageRequestModel.Location1, CanonicalName = pageRequestModel.Location2, ShowBreadcrumb = true, }; var expectedBreadcrumbModel = new BreadcrumbViewModel { Breadcrumbs = new List <BreadcrumbItemViewModel> { new BreadcrumbItemViewModel { Route = "/", Title = "Root", }, new BreadcrumbItemViewModel { Route = "/a-route", Title = "A title", }, }, }; var controller = BuildPagesController(mediaTypeName); A.CallTo(() => FakePagesControlerHelpers.GetContentPageAsync(A <string> .Ignored, A <string> .Ignored)).Returns(expectedResult); A.CallTo(() => FakeMapper.Map <DocumentViewModel>(A <ContentPageModel> .Ignored)).Returns(A.Fake <DocumentViewModel>()); A.CallTo(() => FakeMapper.Map <BreadcrumbViewModel?>(A <ContentPageModel> .Ignored)).Returns(expectedBreadcrumbModel); // Act var result = await controller.Document(pageRequestModel).ConfigureAwait(false); // Assert A.CallTo(() => FakePagesControlerHelpers.GetContentPageAsync(A <string> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeMapper.Map <DocumentViewModel>(A <ContentPageModel> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeMapper.Map <BreadcrumbViewModel>(A <ContentPageModel> .Ignored)).MustHaveHappenedOnceExactly(); var jsonResult = Assert.IsType <OkObjectResult>(result); _ = Assert.IsAssignableFrom <DocumentViewModel>(jsonResult.Value); controller.Dispose(); }
// GET: Breadcrumb public override ActionResult Index() { List <Models.Component.Breadcrumb> breadcrumbMenu = new List <Models.Component.Breadcrumb>(); BreadcrumbViewModel breadcrumbViewModel = new BreadcrumbViewModel(); Item currentItem = Sitecore.Context.Item; // Current sitecore item Item homePage = Sitecore.Context.Database.GetItem(Sitecore.Context.Site.RootPath + Sitecore.Context.Site.StartItem); bool isLasItem = false; Item MainNavigationItem = null; while (currentItem.ID != new ID(homePage.ID.ToGuid())) { if (!isLasItem) { MainNavigationItem = currentItem; // add parent item to breadcrumb object (a list of parent items) breadcrumbMenu.Add(new Breadcrumb { IsLastItem = !isLasItem ? true : false, Url = Sitecore.Links.LinkManager.GetItemUrl(currentItem), Text = currentItem.Fields["Title"].ToString() }); currentItem = currentItem.Parent; isLasItem = true; continue; } breadcrumbMenu.Add(new Breadcrumb { IsLastItem = !isLasItem ? true : false, Url = Sitecore.Links.LinkManager.GetItemUrl(currentItem), Text = currentItem.Fields["Title"].ToString() }); currentItem = currentItem.Parent; } breadcrumbMenu.Add(new Breadcrumb { IsLastItem = !isLasItem ? true : false, Url = Sitecore.Links.LinkManager.GetItemUrl(currentItem), Text = currentItem.Fields["Title"].ToString() }); breadcrumbMenu.Reverse(); breadcrumbViewModel.MainBreadcrumbs = breadcrumbMenu; if (MainNavigationItem.Children.Count > 0) { var model = SitecoreContext.GetItem <MenuItem>(MainNavigationItem.Children.FirstOrDefault().ID.ToGuid()); breadcrumbViewModel.SubMenus = model.NavigationItems.ToList(); } return(View("~/Views/Components/Breadcrumb.cshtml", breadcrumbViewModel)); }
protected virtual BreadcrumbViewModel CreateBreadcrumbViewModel(GetProductBreadcrumbParam parameters, IEnumerable <CategoryViewModel> categoriesPath) { var breadcrumbViewModel = new BreadcrumbViewModel { ActivePageName = HttpUtility.HtmlEncode(parameters.ProductName) }; var stack = new Stack <BreadcrumbItemViewModel>(); CreateBreadcrumbItemsForCategories(stack, GetCategoriesWithoutRoot(categoriesPath), parameters.CultureInfo, parameters.BaseUrl); CreateRootBreadcrumbItem(stack, parameters.HomeUrl, parameters.CultureInfo); UnrollStackIntoViewModel(stack, breadcrumbViewModel); return(breadcrumbViewModel); }
public PartialViewResult GetCategoryBreadcrumb(Category category) { var allowedCategories = _categoryService.GetAllowedCategories(UsersRole); using (UnitOfWorkManager.NewUnitOfWork()) { var viewModel = new BreadcrumbViewModel { Categories = _categoryService.GetCategoryParents(category,allowedCategories), Category = category }; return PartialView("GetCategoryBreadcrumb", viewModel); } }
public PartialViewResult GetTopicBreadcrumb(Topic topic) { var category = topic.Category; var allowedCategories = _categoryService.GetAllowedCategories(UsersRole); using (UnitOfWorkManager.NewUnitOfWork()) { var viewModel = new BreadcrumbViewModel { Categories = _categoryService.GetCategoryParents(category, allowedCategories), Topic = topic }; if (!viewModel.Categories.Any()) { viewModel.Categories.Add(topic.Category); } return PartialView("GetCategoryBreadcrumb", viewModel); } }