public new static XtracurEventsIndexWeekViewModel Build(XtracurDivision xtracurDivision, DateTime?fromDate, int?showImmediateEventId, int?showImmediateRecurrenceIndex) { var language = CultureHelper.CurrentLanguage; var weekFromDate = DateTimeHelper.GetWeekStart(fromDate); var weekToDate = weekFromDate.AddDays(7); var previousWeekFromDate = weekFromDate.AddDays(-7); var nextWeekFromDate = weekFromDate.AddDays(7); var currentWeekFromDate = DateTimeHelper.GetWeekStart(DateTime.Today); var events = EventsViewModelHelper.GetXtracurEvents(xtracurDivision, weekFromDate, weekToDate, showImmediateEventId, showImmediateRecurrenceIndex).ToList(); var weekDays = events.Where(e => e.Start >= weekFromDate) .GroupBy(vm => vm.Start.Date) .OrderBy(g => g.Key) .Select(g => EventsDayViewModel.Build(g.Key, g.AsEnumerable())); var earlierEvents = events.Where(e => e.Start < weekFromDate); return(new XtracurEventsIndexWeekViewModel { Alias = xtracurDivision.Alias, Title = xtracurDivision.GetNameByLanguage(language), EarlierEvents = earlierEvents, Days = weekDays, WeekDisplayText = DateTimeHelper.GetWeekDisplayText(language, weekFromDate, weekToDate), PreviousWeekMonday = DateTimeHelper.GetDateStringForWeb(previousWeekFromDate), WeekMonday = DateTimeHelper.GetDateStringForWeb(weekFromDate), NextWeekMonday = DateTimeHelper.GetDateStringForWeb(nextWeekFromDate), IsCurrentWeekReferenceAvailable = (currentWeekFromDate != weekFromDate), HasEventsToShow = events.Any(e => !e.IsShowImmediateHidden), Breadcrumb = new Breadcrumb() { BreadcrumbHelper.GetBreadcrumbRootItem(false), BreadcrumbHelper.GetBreadcrumbXtracurEventsItem(xtracurDivision, true) } }); }
public InsertDiskViewModel() { _rootPath = Settings.Default["Path"].ToString(); if (string.IsNullOrWhiteSpace(_rootPath)) { BreadcrumbHelper.GotoPage(new NoPathPage()); } SelectedPassenger = UserSelection.SelectedPassenger; Drives = DriveInfo.GetDrives().Where(d => d.DriveType == DriveType.Removable).ToList(); ListenDrive(); PropertyChanged += (sender, args) => { if (args.PropertyName == "SelectedDrive") { DriveInfo info = new DriveInfo(SelectedDrive); Application.Current.Dispatcher.Invoke(() => { BreadcrumbHelper.GotoPage(new DrivePage(info)); }); } }; }
public ActionResult Index(string productName) { CategoryModel category; try { category = productsService.GetCategoryByProduct(productName); } catch (ClientException) { return(NotFoundResult()); } ProductModel product = category.Products.Single(a => a.Name == productName); ProductViewModel indexViewModel = new ProductViewModel( ContentSectionHelper.MapContentSectionsToViewModels(product.ContentSections), product.GalleryImages.Select(b => ImageHelper.MapImageToViewModel(b)), product.OverviewParagraphs, product.Features ) { Breadcrumb = BreadcrumbHelper.GetProductBreadcrumb(Url, category.Title, category.Name, product.Title, product.Name), MainHeading = product.Title, BannerImageUrl = TourtechUrlHelper.GetImageUrl(product.BannerImageRelativeUrl), Title = product.MetaData.Title, MetaDescription = product.MetaData.MetaDescription }; SetLayout(indexViewModel); return(View(indexViewModel)); }
public ActionResult Index(string categoryName) { CategoryModel category; try { category = productsService.GetCategory(categoryName); } catch (ClientException) { return(NotFoundResult()); } CategoryViewModel viewModel = new CategoryViewModel() { Breadcrumb = BreadcrumbHelper.GetCategoryBreadcrumb(Url, category.Title, categoryName), MainHeading = category.Title, Sections = ContentSectionHelper.MapContentSectionsToViewModels(category.ContentSections), Products = ProductHelper.MapProductsToViewModels(category.Products), BannerImageUrl = TourtechUrlHelper.GetImageUrl(category.BannerImageRelativeUrl), Title = category.MetaData.Title, MetaDescription = category.MetaData.MetaDescription } ; SetLayout(viewModel); return(View(viewModel)); }
public void RenderEntity(int id) { EntityDTO dto = data.GetOneEntity(id); dto.ExtractProperties(); ProcessStrategy2 st = new ProcessStrategy2(); PageResponseDTO response = new PageResponseDTO(); response.BreadCrumbContent = BreadcrumbHelper.BuildBreadcrumbContent(dto); response.Header = dto.Name; response.Content = MainContentBuilder.BuildContent(dto); switch (dto.Type) { case 111: response.RenderType = "process"; break; case 142: response.RenderType = "subprocess"; break; case 145: response.RenderType = "st2020"; break; default: break; } this.view.RenderContent(response); }
public static XtracurEventsIndexMonthViewModel Build(XtracurDivision xtracurDivision, DateTime?month, int?showImmediateEventId, int?showImmediateRecurrenceIndex) { var language = CultureHelper.CurrentLanguage; var firstDayOfCurrentMonth = DateTimeHelper.GetFirstDayOfCurrentMonth(); var firstDayOfChosenMonth = DateTimeHelper.GetFirstDayOfMonth(month); var firstDayOfTheNextMonth = DateTimeHelper.GetFirstDayOfTheNextMonth(firstDayOfChosenMonth); var firstDayOfThePreviousMonth = DateTimeHelper.GetFirstDayOfThePreviousMonth(firstDayOfChosenMonth); var eventGroupings = EventsViewModelHelper.GetXtracurEventGroupings(xtracurDivision, firstDayOfChosenMonth, firstDayOfTheNextMonth, showImmediateEventId, showImmediateRecurrenceIndex); return(new XtracurEventsIndexMonthViewModel { Alias = xtracurDivision.Alias, Title = xtracurDivision.GetNameByLanguage(language), IsCurrentMonthReferenceAvailable = firstDayOfCurrentMonth != firstDayOfChosenMonth, ChosenMonthDisplayText = GetMonthDisplayText(firstDayOfChosenMonth), PreviousMonthDisplayText = GetPreviousMonthDisplayText(firstDayOfThePreviousMonth), PreviousMonthDate = DateTimeHelper.GetDateStringForWeb(firstDayOfThePreviousMonth), NextMonthDisplayText = GetNextMonthDisplayText(firstDayOfTheNextMonth), NextMonthDate = DateTimeHelper.GetDateStringForWeb(firstDayOfTheNextMonth), EventGroupings = eventGroupings, ShowGroupingCaptions = eventGroupings.Count() > 1, HasEventsToShow = eventGroupings.Any(eg => eg.Events.Any(e => !e.IsShowImmediateHidden)), Breadcrumb = new Breadcrumb() { BreadcrumbHelper.GetBreadcrumbRootItem(false), BreadcrumbHelper.GetBreadcrumbXtracurEventsItem(xtracurDivision, true) } }); }
public ActionResult Index() { IEnumerable <CategoryViewModel> categories = productsService.GetCategories().Select(a => new CategoryViewModel() { Title = a.Title, ImageUrl = TourtechUrlHelper.GetImageUrl(a.ImageRelativeUrl), LinkUrl = TourtechUrlHelper.GetCategoryUrl(a.Name), ComingSoon = a.ComingSoon } ) ; PageModel productsPageContent = pageContentService.ProductsPage; ProductsViewModel viewModel = new ProductsViewModel() { Breadcrumb = BreadcrumbHelper.GetProductsBreadcrumb(Url), MainHeading = productsPageContent.MainHeading, Categories = categories, Title = productsPageContent.MetaData.Title, MetaDescription = productsPageContent.MetaData.MetaDescription } ; SetBannerToDefault(viewModel); SetLayout(viewModel); return(View(viewModel)); }
public static StudyProgramShowViewModel Build(IEnumerable <StudyProgram> studyPrograms, PublicDivision publicDivision) { var firstStudyProgram = studyPrograms.First(); var session = firstStudyProgram.Session; var admissionYear = firstStudyProgram.AdmissionYear; var language = CultureHelper.CurrentLanguage; var currentStudyYear = StudyYearHelper.GetDefaultCurrentStudyYear(session); var previousStudyYear = StudyYearHelper.GetPreviousStudyYear(session); var studentGroups = GetStudentGroups(studyPrograms); var studentGroupsForCurrentStudyYear = studentGroups.Where(sg => sg.CurrentStudyYear == currentStudyYear); var studentGroupsForPreviousStudyYear = previousStudyYear.IsWebAvailable ? studentGroups.Where(sg => sg.CurrentStudyYear == previousStudyYear) : new List <StudentGroup>(); return(new StudyProgramShowViewModel { StudyProgramDisplayText = GetStudyProgramDisplayText(firstStudyProgram), AdmissionYearText = GetAdmissionYearText(admissionYear), StudentGroupsForCurrentStudyYear = studentGroupsForCurrentStudyYear.Select(sg => StudentGroupItemViewModel.Build(sg, publicDivision)), StudentGroupsForPreviousStudyYear = studentGroupsForPreviousStudyYear.Select(sg => StudentGroupItemViewModel.Build(sg, publicDivision)), CurrentStudyYearDisplayText = currentStudyYear.GetDisplayNameByLanguage(language), PreviousStudyYearDisplayText = previousStudyYear.GetDisplayNameByLanguage(language), PublicDivisionAlias = publicDivision.Alias, Breadcrumb = new Breadcrumb() { BreadcrumbHelper.GetBreadcrumbRootItem(false), BreadcrumbHelper.GetBreadcrumbPublicDivisionItem(publicDivision, false), BreadcrumbHelper.GetBreadcrumbCourseItem(publicDivision, firstStudyProgram, true), } }); }
/// <summary> /// Renders a Twitter Bootstrap breadcrumb component. /// </summary> /// <param name="helper">The Html helper.</param> /// <param name="actionLinks">The action links.</param> /// <param name="htmlAttributes">The HTML attributes.</param> /// <returns>returns a breadcrumb html string</returns> /// <example>@Html.Breadcrumb(links, new { @class="span5 offset1" })</example> public static MvcHtmlString Breadcrumb(this HtmlHelper helper, IEnumerable <MenuItem> actionLinks, object htmlAttributes = null) { BreadcrumbHelper breadcrumbHelper = new BreadcrumbHelper(helper, actionLinks, htmlAttributes); return(MvcHtmlString.Create(breadcrumbHelper.Render())); }
public ActionResult Index() { IEnumerable <RetailerViewModel> retailers = retailerService.GetRetailers().Select( a => new RetailerViewModel() { Name = a.Name, DesktopImageUrl = TourtechUrlHelper.GetImageUrl(a.DesktopImageRelativeUrl), MobileImageUrl = TourtechUrlHelper.GetImageUrl(a.MobileImageRelativeUrl), WebsiteUrl = a.WebsiteUrl, WebsiteUrlForDisplay = a.WebsiteUrlForDisplay, BackgroundColourHex = a.BackgroundColourHex, TextColourHex = a.TextColourHex } ) ; PageModel whereToBuyPage = pageContentService.WhereToBuyPage; WhereToBuyViewModel viewModel = new WhereToBuyViewModel() { Breadcrumb = BreadcrumbHelper.GetWhereToBuyBreadcrumb(Url, whereToBuyPage.MainHeading), MainHeading = whereToBuyPage.MainHeading, Retailers = retailers, Title = whereToBuyPage.MetaData.Title, MetaDescription = whereToBuyPage.MetaData.MetaDescription }; SetBannerToDefault(viewModel); SetLayout(viewModel); return(View(viewModel)); }
public static Breadcrumb GetBreadcrumb(PublicDivision publicDivision, StudyProgram studyProgram) { return(new Breadcrumb() { BreadcrumbHelper.GetBreadcrumbRootItem(false), BreadcrumbHelper.GetBreadcrumbPublicDivisionItem(publicDivision, false), BreadcrumbHelper.GetBreadcrumbCourseItem(publicDivision, studyProgram, false), BreadcrumbHelper.GetBreadcrumbTimeTableItem() }); }
public NoPathPage() { InitializeComponent(); var path = Settings.Default["Path"].ToString(); if (!string.IsNullOrWhiteSpace(path)) { BreadcrumbHelper.GotoPage(new InsertDiskPage()); } }
public static DivisionIndexViewModel Build(IEnumerable <PublicDivision> publicDivisions) { return(new DivisionIndexViewModel { Divisions = publicDivisions.Select(pd => DivisionItemViewModel.Build(pd)), Breadcrumb = new Breadcrumb { BreadcrumbHelper.GetBreadcrumbRootItem(true) } }); }
public static XtracurEventsSearchViewModel Build(XtracurDivision xtracurDivision, string query, int?offset, bool?showPast) { LanguageCode language = CultureHelper.CurrentLanguage; bool isEmptyQuery = String.IsNullOrWhiteSpace(query); int totalCount; var today = DateTime.Today; IEnumerable <XtracurEventItemViewModel> events = Enumerable.Empty <XtracurEventItemViewModel>(); if (!showPast.HasValue && !offset.HasValue) { var upcomingEvents = GetEvents(xtracurDivision, query, 0, today, DateTimeHelper.MaxValue, out totalCount); if (upcomingEvents.Any()) { events = upcomingEvents; showPast = false; } else { var pastEvents = GetEvents(xtracurDivision, query, 0, DateTimeHelper.MinValue, today.AddDays(1), out totalCount); if (pastEvents.Any()) { events = pastEvents; showPast = true; } } } else { var fromDate = showPast.Value ? DateTimeHelper.MinValue : today; var toDate = showPast.Value ? today.AddDays(1) : DateTimeHelper.MaxValue; events = GetEvents(xtracurDivision, query, offset ?? 0, fromDate, toDate, out totalCount); } IEnumerable <XtracurEventsSearchPagerItemViewModel> pagerItems = GeneratePagerItems(offset ?? 0, (totalCount - 1) / ItemsOnPageCount + 1); return(new XtracurEventsSearchViewModel { Alias = xtracurDivision.Alias, Title = xtracurDivision.GetNameByLanguage(language), Events = events, PagerItems = pagerItems, ShowPager = pagerItems.Any(pi => pi.IsEnabled && !pi.IsActive), ShowPast = showPast ?? false, ShowUpcoming = showPast.HasValue ? !(showPast ?? false) : false, IsEmptyQuery = isEmptyQuery, Offset = offset ?? 0, QueryDisplayText = query, Breadcrumb = new Breadcrumb() { BreadcrumbHelper.GetBreadcrumbRootItem(false), BreadcrumbHelper.GetBreadcrumbXtracurEventsItem(xtracurDivision, false), BreadcrumbHelper.GetBreadcrumbXtracurSearchItem(true) } }); }
public void Merger_NeverOverwriteNullMergeCriteria_DoesntOverwriteWithNulls() { var sequence = SequencedComplexItemBuilder.GetNewNullValueSequence(); string mergeCriteriaKey = BreadcrumbHelper <SequencedComplexItem> .Of(s => s.StringValue); var neverOverwriteNullCriteria = new NeverOverwriteOldWithNull(mergeCriteriaKey); var nonDefaultMergeCriteria = new List <IMergeCriteria>(new[] { neverOverwriteNullCriteria }); var mergedValue = (SequencedComplexItem)_merger.Merge(sequence, nonDefaultMergeCriteria: nonDefaultMergeCriteria); Assert.AreEqual(sequence[0].StringValue, mergedValue.StringValue); }
public static EducatorEventsIndexViewModel Build(Session session, string educatorLastNameQuery) { return(new EducatorEventsIndexViewModel { EducatorLastNameQuery = educatorLastNameQuery, Educators = EducatorEventsHelper.SearchEducatorsByLastName(session, educatorLastNameQuery), Breadcrumb = new Breadcrumb() { BreadcrumbHelper.GetBreadcrumbRootItem(false), BreadcrumbHelper.GetBreadcrumbEducatorsItem(true), } }); }
public static EducatorEventsShowAllViewModel Build(EducatorMasterPerson educatorMasterPerson, int?next) { bool showNext = next.HasValue && next.Value > 0; LanguageCode language = CultureHelper.CurrentLanguage; string educatorDisplayText = educatorMasterPerson.GetDisplayNameByLanguage(language); string educatorLongDisplayText = educatorMasterPerson.GetLongDisplayNameByLanguage(language); DateTime summerTermBoundary = new DateTime(DateTime.Now.Month == 1 ? DateTime.Now.Year - 1 : DateTime.Now.Year, 8, 1); DateTime winterTermBoundary = new DateTime(DateTime.Now >= summerTermBoundary && DateTime.Now.Month > 1 ? DateTime.Now.Year + 1 : DateTime.Now.Year, 2, 1); DateTime nextSummerTermBoundary = new DateTime(summerTermBoundary.Year + 1, summerTermBoundary.Month, summerTermBoundary.Day); DateTime nextWinterTermBoundary = new DateTime(winterTermBoundary.Year + 1, winterTermBoundary.Month, winterTermBoundary.Day); bool isSpringTerm = winterTermBoundary < DateTime.Now && DateTime.Now < summerTermBoundary; DateTime fromDate = showNext ? (isSpringTerm ? summerTermBoundary : winterTermBoundary) : (isSpringTerm ? winterTermBoundary : summerTermBoundary); DateTime toDate = showNext ? (isSpringTerm ? nextWinterTermBoundary : nextSummerTermBoundary) : (isSpringTerm ? summerTermBoundary : winterTermBoundary); string title = string.Format("{0} {1}", Resources.Resources.TimetableForEducator, educatorLongDisplayText); IEnumerable <StudyEventAggregatedDayItemViewModel> educatorEventsDays = StudyEventsViewModelHelper.GetEducatorAggregatedEventsDays(educatorMasterPerson, fromDate, toDate); return(new EducatorEventsShowAllViewModel { Next = next, From = fromDate, To = toDate, EducatorDisplayText = educatorDisplayText, EducatorLongDisplayText = educatorLongDisplayText, DateRangeDisplayText = string.Format("{0:d MMMM yyyy} - {1:d MMMM yyyy}", fromDate, toDate), Title = title, EducatorMasterId = educatorMasterPerson.Id, EducatorEventsDays = educatorEventsDays, IsSpringTerm = isSpringTerm, SpringTermLinkAvailable = isSpringTerm == showNext, AutumnTermLinkAvailable = isSpringTerm != showNext, HasEvents = educatorEventsDays.Any(seadivm => seadivm.DayStudyEvents.Any()), Breadcrumb = new Breadcrumb() { BreadcrumbHelper.GetBreadcrumbRootItem(false), BreadcrumbHelper.GetBreadcrumbEducatorsItem(false), new BreadcrumbItem { IsActive = true, DisplayText = educatorDisplayText, } } }); }
public static HomeIndexViewModel Build(IEnumerable <PublicDivision> publicDivisions, IEnumerable <XtracurDivision> xtracurDivisions) { return(new HomeIndexViewModel { Divisions = publicDivisions.Select(pd => DivisionItemViewModel.Build(pd)), XtracurDivisions = xtracurDivisions .Where(xd => xd.Alias != "PhysTraining") .Select(xd => XtracurDivisionItemViewModel.Build(xd)), PhysTrainingDivisions = xtracurDivisions .Where(xd => xd.Alias == "PhysTraining") .Select(xd => XtracurDivisionItemViewModel.Build(xd)), Breadcrumb = new Breadcrumb { BreadcrumbHelper.GetBreadcrumbRootItem(true) } }); }
public MainWindow() { InitializeComponent(); var appTheme = Settings.Default["AppTheme"].ToString(); var themeAccent = Settings.Default["ThemeAccent"].ToString(); var path = Settings.Default["Path"].ToString(); ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent(themeAccent), ThemeManager.GetAppTheme(appTheme)); BreadcrumbHelper.MainWindow = this; if (!string.IsNullOrWhiteSpace(path)) { BreadcrumbHelper.GotoPage(new PassengersView()); } else { BreadcrumbHelper.GotoPage(new NoPathPage()); } }
public static DivisionShowViewModel Build(PublicDivision publicDivision) { alias = publicDivision.Alias; var publicDivisionStudentGroups = publicDivision.StudentGroups; var language = CultureHelper.CurrentLanguage; var studyProgramNameLevelCombinations = publicDivisionStudentGroups.Where(sg => sg.StudyProgram != null) .Select(sg => sg.StudyProgram) .Distinct() .GroupBy(sp => new { Name = sp.GetNameByLanguage(language), StudyLevelName = sp.StudyLevel.GetNameByLanguage(language), }) .Select(g => new StudyProgramNameLevelCombination { Name = g.Key.Name, StudyLevelName = g.Key.StudyLevelName, StudyPrograms = g.AsEnumerable() }) .OrderBy(x => x.StudyLevelName); return(new DivisionShowViewModel { Title = GetTitle(publicDivision), StudyProgramsTitle = GetStudyProgramsTitle(studyProgramNameLevelCombinations), StudyProgramLevels = studyProgramNameLevelCombinations .GroupBy(x => x.StudyLevelName) .Select(g => StudyProgramLevelViewModel.Build(g.Key, g, publicDivision)), Breadcrumb = new Breadcrumb() { BreadcrumbHelper.GetBreadcrumbRootItem(false), new BreadcrumbItem { IsActive = true, DisplayText = publicDivision.GetNameByLanguage(language) } } }); }
public static EducatorEventsShowViewModel Build(EducatorMasterPerson educatorMasterPerson, DateTime?weekMonday) { LanguageCode language = CultureHelper.CurrentLanguage; DateTime weekStart = weekMonday.HasValue ? weekMonday.Value.AddDays(1 - (int)weekMonday.Value.DayOfWeek).Date : DateTime.Now.AddDays(1 - (int)DateTime.Now.DayOfWeek).Date; DateTime weekEnd = weekStart.AddDays(7); string educatorDisplayText = educatorMasterPerson.GetDisplayNameByLanguage(language); string educatorFullDisplayText = educatorMasterPerson.GetLongDisplayNameByLanguage(language); return(new EducatorEventsShowViewModel { EducatorDisplayText = educatorDisplayText, EducatorFullDisplayText = educatorFullDisplayText, Title = string.Format("{0} {1}", Resources.Resources.TimetableForEducator, educatorFullDisplayText), EducatorMasterId = educatorMasterPerson.Id, EducatorEventsDays = StudyEventsViewModelHelper.GetEducatorEventsDayViewModels(educatorMasterPerson, weekStart, weekEnd), PreviousWeekMonday = weekStart.AddDays(-7).ToString("yyyy-MM-dd"), WeekStart = weekStart, WeekMonday = weekStart.ToString("yyyy-MM-dd"), NextWeekMonday = weekStart.AddDays(7).ToString("yyyy-MM-dd"), WeekDisplayText = language == LanguageCode.English ? string.Format("{0:d MMMM} – {1:d MMMM}", weekStart, weekEnd.AddDays(-1)) : string.Format("{0:d MMMM} – {1:d MMMM}", weekStart, weekEnd.AddDays(-1)), IsCurrentWeekReferenceAvailable = weekStart != DateTime.Now.AddDays(1 - (int)DateTime.Now.DayOfWeek).Date, Breadcrumb = new Breadcrumb() { BreadcrumbHelper.GetBreadcrumbRootItem(false), BreadcrumbHelper.GetBreadcrumbEducatorsItem(false), new BreadcrumbItem { IsActive = true, DisplayText = educatorDisplayText, } } }); }
private void ListenPropertyChanged() { PropertyChanged += (sender, args) => { switch (args.PropertyName) { case "SelectedPassenger": UserSelection.SelectedPassenger = SelectedPassenger; CheckPassengerFolders(SelectedPassenger); BreadcrumbHelper.GotoPage(new InsertDiskPage()); break; case "ShowPhoto": case "ShowVideo": case "SearchTerm": Passengers = _unfilteredPassengers .Where(x => (x.IsPhoto == ShowPhoto && x.IsVideo == ShowVideo) || (ShowPhoto == ShowVideo)) .Where(x => string.IsNullOrWhiteSpace(SearchTerm) || x.FullName.ToLower().Contains(SearchTerm.ToLower())) .ToList(); break; } }; }
private void SettingsClick(object sender, RoutedEventArgs e) { BreadcrumbHelper.GotoPage(new SettingsPage()); }
public BaseViewModel() { GoBackCommand = new MyCommand(null, () => BreadcrumbHelper.GoBack()); GoToPassengerSelectionCommand = new MyCommand(null, () => BreadcrumbHelper.GotoPage(new PassengersView())); }
public IActionResult ProductsListApi(ProductSearchModel searchModel, string viewName = null) { searchModel.Count = _catalogSettings.NumberOfProductsPerPage; IList <int> categoryIds = null; if (searchModel.CategoryId.HasValue && searchModel.CategoryId.Value > 0) { categoryIds = new List <int>() { searchModel.CategoryId.Value }; var fullCategoryTree = _categoryService.GetFullCategoryTree(); var currentCategory = fullCategoryTree.FirstOrDefault(x => x.Id == searchModel.CategoryId.Value); //set breadcrumb BreadcrumbHelper.SetCategoryBreadcrumb(currentCategory, fullCategoryTree); if (_catalogSettings.DisplayProductsFromChildCategories) { if (currentCategory != null) { var childIds = currentCategory.Children.SelectManyRecursive(x => x.Children).Select(x => x.Id); categoryIds = categoryIds.Concat(childIds).ToList(); } } } //create order by expression Expression <Func <Product, object> > orderByExpression = null; switch (searchModel.SortColumn?.ToLower()) { case "name": orderByExpression = product => product.Name; break; case "createdon": orderByExpression = product => product.CreatedOn; break; case "price": orderByExpression = product => product.Price; break; case "popularity": default: orderByExpression = product => product.PopularityIndex; searchModel.SortOrder = SortOrder.Descending; searchModel.SortColumn = "popularity"; break; } IList <int> roleIds = CurrentUser?.Roles?.Select(x => x.Id).ToList(); var products = _productService.GetProducts(out int totalResults, out decimal availableFromPrice, out decimal availableToPrice, out Dictionary <int, string> availableManufacturers, out Dictionary <int, string> availableVendors, out Dictionary <string, List <string> > availableFilters, searchText: searchModel.Search, filterExpression: searchModel.Filters, published: true, tags: searchModel.Tags, vendorIds: searchModel.VendorIds, manufacturerIds: searchModel.ManufacturerIds, categoryids: categoryIds, roleIds: roleIds, fromPrice: searchModel.FromPrice, toPrice: searchModel.ToPrice, sortOrder: searchModel.SortOrder, orderByExpression: orderByExpression, page: searchModel.Page, count: searchModel.Count); var productModels = products.Select(_productModelFactory.Create).ToList(); searchModel.AvailableFromPrice = availableFromPrice; searchModel.AvailableToPrice = availableToPrice; searchModel.AvailableFilters = availableFilters; searchModel.AvailableManufacturers = availableManufacturers; searchModel.AvailableVendors = availableVendors; //get the category if (searchModel.CategoryId > 0) { var category = _categoryService.Get(searchModel.CategoryId.Value); if (category != null) { SeoMetaHelper.SetSeoData(category.Name, category.Description, category.Description); } } if (viewName.IsNullEmptyOrWhiteSpace()) { viewName = "ProductsList"; } return(R.Success.With("products", productModels) .WithParams(searchModel) .WithGridResponse(totalResults, searchModel.Page, searchModel.Count, searchModel.SortColumn, searchModel.SortOrder) .WithView(viewName) .Result); }
public override void OnActionExecuted(ActionExecutedContext filterContext) { var model = (IBreadcrumbs)filterContext.Controller.ViewData.Model; model.Breadcrumbs = BreadcrumbHelper.GetBreadCrumbs(string.Format("{0}", filterContext.RouteData.DataTokens["area"]), Page); }
/// <summary> /// Initializes a new instance of the <see cref="SequencedComplexItemStringValueMergeCriteria_NeverOverwriteSequenceID1"/> class. /// </summary> public SequencedComplexItemStringValueMergeCriteria_NeverOverwriteSequenceID1() { // this class has a very specific target class/property ActivateAt = BreadcrumbHelper <SequencedComplexItem> .Of(s => s.StringValue); }
public IActionResult Index(int id) { if (id < 1) { return(NotFound()); } var product = _productService.Get(id); if (!product.IsPublic() && !CurrentUser.Can(CapabilitySystemNames.EditProduct)) { return(NotFound()); } //is the product restricted to roles if (product.RestrictedToRoles) { var userRoleIds = CurrentUser?.Roles?.Select(x => x.Id).ToList(); if (userRoleIds == null || product.EntityRoles.All(x => !userRoleIds.Contains(x.RoleId))) { return(NotFound()); } } var productModel = _productModelFactory.Create(product); var response = R.Success; response.With("product", productModel); if (_catalogSettings.EnableRelatedProducts) { var productRelations = _productRelationService.GetByProductId(id, ProductRelationType.RelatedProduct, 1, _catalogSettings.NumberOfRelatedProducts); if (productRelations.Any()) { var relatedProductsModel = productRelations.Select(x => x.DestinationProduct).Select(_productModelFactory.Create).ToList(); response.With("relatedProducts", relatedProductsModel); } } if (product.HasVariants) { //any variants var variants = _productVariantService.GetByProductId(product.Id); var variantModels = new List <object>(); foreach (var variant in variants) { _priceAccountant.GetProductPriceDetails(product, null, variant.Price, out decimal priceWithoutTax, out decimal tax, out decimal taxRate, out _); var variantObject = new { attributes = new Dictionary <string, string>(), price = _priceAccountant .ConvertCurrency( (_taxSettings.DisplayProductPricesWithoutTax ? priceWithoutTax : priceWithoutTax + tax), ApplicationEngine.CurrentCurrency).ToCurrency(), isAvailable = !variant.TrackInventory || (variant.TrackInventory && variant.IsAvailableInStock(product)), sku = !variant.Sku.IsNullEmptyOrWhiteSpace() ? variant.Sku : product.Sku, gtin = !variant.Gtin.IsNullEmptyOrWhiteSpace() ? variant.Gtin : product.Gtin, mpn = !variant.Mpn.IsNullEmptyOrWhiteSpace() ? variant.Mpn : product.Mpn }; foreach (var pva in variant.ProductVariantAttributes) { variantObject.attributes.Add(pva.ProductAttribute.Label, pva.ProductAttributeValue.AvailableAttributeValue.Value); } variantModels.Add(variantObject); } if (variantModels.Any()) { response.With("variants", variantModels); } productModel.IsAvailable = variantModels.Any(x => (bool)((dynamic)x).isAvailable); } //downloads if (product.IsDownloadable) { var downloads = _downloadService.GetWithoutBytes(x => x.ProductId == product.Id && !x.RequirePurchase).ToList(); if (CurrentUser.IsVisitor()) { downloads = downloads.Where(x => !x.RequireLogin).ToList(); } var downloadModels = downloads.Select(_productModelFactory.Create).ToList(); response.With("downloads", downloadModels); } //reviews if (_catalogSettings.EnableReviews) { var reviews = _reviewService.Get(x => x.ProductId == product.Id, 1, _catalogSettings.NumberOfReviewsToDisplayOnProductPage).ToList(); if (reviews.Any()) { var reviewModels = reviews.Select(x => { var model = _modelMapper.Map <ReviewModel>(x); model.DisplayName = x.Private ? _catalogSettings.DisplayNameForPrivateReviews : x.User?.Name; if (model.DisplayName.IsNullEmptyOrWhiteSpace()) { model.DisplayName = T("Store Customer"); } return(model); }).ToList(); response.With("reviews", reviewModels); } } //breadcrumbs if (_generalSettings.EnableBreadcrumbs) { var categoryTree = _categoryService.GetFullCategoryTree(); var category = product.Categories?.FirstOrDefault(); var currentCategoryFull = categoryTree.FirstOrDefault(x => x.Id == category?.Id); BreadcrumbHelper.SetCategoryBreadcrumb(currentCategoryFull, categoryTree); SetBreadcrumbToRoute(product.Name, RouteNames.SingleProduct, new { seName = product.SeoMeta.Slug }, localize: false); } //seo data SeoMetaHelper.SetSeoData(product.Name, product.Description, product.Description); return(response.With("preview", !product.Published).Result); }