public ActionResult Index(string id) { var category = _dataContext.Categories.Single(m => m.UrlFriendlyName == id); var articles = _dataContext.Articles .Include(m => m.HostSite) .Include(m => m.Category) .Where(m => m.Category.Id == category.Id) .Where(m => m.IsPublished) .Where(m => m.HostSite.IsActive).ToList(); var model = new CategoryIndexViewModel { Category = category, Articles = articles }; return View(model); }
public override async Task <IViewProviderResult> BuildIndexAsync(CategoryAdmin categoryBase, IViewProviderContext updater) { var feature = await _featureFacade.GetFeatureByIdAsync("Plato.Issues.Categories"); if (feature == null) { throw new Exception($"No feature could be found for the Id 'Plato.Issues.Categories'"); } var viewModel = new CategoryIndexViewModel() { Options = new CategoryIndexOptions() { FeatureId = feature.Id, CategoryId = categoryBase?.Id ?? 0 } }; return(Views( View <CategoryBase>("Admin.Index.Header", model => categoryBase).Zone("header").Order(1), View <CategoryIndexViewModel>("Admin.Index.Tools", model => viewModel).Zone("tools").Order(1), View <CategoryIndexViewModel>("Admin.Index.Content", model => viewModel).Zone("content").Order(1) )); }
public override async Task <IViewProviderResult> BuildIndexAsync(Question viewModel, IViewProviderContext updater) { // Ensure we explicitly set the featureId var feature = await _featureFacade.GetFeatureByIdAsync("Plato.Questions.Categories"); if (feature == null) { return(default(IViewProviderResult)); } var categoryIndexViewModel = new CategoryIndexViewModel() { Options = new CategoryIndexOptions() { FeatureId = feature.Id } }; return(Views( View <CategoryIndexViewModel>("Questions.Categories.Sidebar", model => categoryIndexViewModel) .Zone("content-right") .Order(1) )); }
public override async Task <IViewProviderResult> BuildIndexAsync(Doc doc, IViewProviderContext updater) { // Ensure we explicitly set the featureId var feature = await _featureFacade.GetFeatureByIdAsync("Plato.Docs.Categories"); if (feature == null) { return(default(IViewProviderResult)); } var categoryIndexViewModel = new CategoryIndexViewModel() { Options = new CategoryIndexOptions() { FeatureId = feature.Id, CategoryId = doc.CategoryId } }; return(Views( View <CategoryIndexViewModel>("Doc.Categories.Index.Content", model => categoryIndexViewModel).Zone("content").Order(1), View <CategoryIndexViewModel>("Doc.Categories.Index.Sidebar", model => categoryIndexViewModel).Zone("content-left").Order(int.MinValue + 10) )); }
public override async Task <IViewProviderResult> BuildDisplayAsync(Doc doc, IViewProviderContext updater) { // Ensure we explicitly set the featureId var feature = await _featureFacade.GetFeatureByIdAsync("Plato.Docs.Categories"); if (feature == null) { return(default(IViewProviderResult)); } // Override breadcrumb configuration within base controller IEnumerable <CategoryAdmin> parentCategories = null; if (doc.CategoryId > 0) { parentCategories = await _categoryStore.GetParentsByIdAsync(doc.CategoryId); } // Get parent entities var parentEntities = await _entityStore.GetParentsByIdAsync(doc.Id); // Build breadcrumb _breadCrumbManager.Configure(builder => { builder.Add(S["Home"], home => home .Action("Index", "Home", "Plato.Core") .LocalNav() ).Add(S["Docs"], home => home .Action("Index", "Home", "Plato.Docs") .LocalNav() ); // Parent categories if (parentCategories != null) { builder.Add(S["Categories"], c => c .Action("Index", "Home", "Plato.Docs.Categories", new RouteValueDictionary() { ["opts.categoryId"] = null, ["opts.alias"] = null }) .LocalNav() ); foreach (var parent in parentCategories) { builder.Add(S[parent.Name], channel => channel .Action("Index", "Home", "Plato.Docs.Categories", new RouteValueDictionary { ["opts.categoryId"] = parent.Id, ["opts.alias"] = parent.Alias, }) .LocalNav() ); } } // Parent entities if (parentEntities != null) { foreach (var parent in parentEntities) { if (parent.Id != doc.Id) { builder.Add(S[parent.Title], channel => channel .Action("Display", "Home", "Plato.Docs", new RouteValueDictionary { ["opts.id"] = parent.Id, ["opts.alias"] = parent.Alias, }) .LocalNav() ); } } } builder.Add(S[doc.Title]); }); // Build view var categoryIndexViewModel = new CategoryIndexViewModel() { Options = new CategoryIndexOptions() { FeatureId = feature.Id, CategoryId = doc.CategoryId } }; return(Views( View <CategoryIndexViewModel>("Doc.Categories.Index.Sidebar", model => categoryIndexViewModel).Zone("sidebar").Order(int.MinValue + 10) )); }
public ActionResult Index() { var model = new CategoryIndexViewModel(); return View(model); }
private CategoryIndexViewModel GetIndexViewModel(CategoryIndexViewModel currModel) { currModel.FilterModel = currModel.FilterModel ?? new CategoryFilterModel(); return(currModel); }
private IEnumerable <ProductCategory> IndexGetSortedCategoryList(IEnumerable <ProductCategory> categorySearchResult, bool isDesc, string col, ref CategoryIndexViewModel viewModel) { viewModel.IsDescTitle = false; viewModel.IsDescId = false; viewModel.SelectedColumn = col; viewModel.IsDesc = isDesc; if (isDesc && col == "title") { categorySearchResult = categorySearchResult.OrderByDescending(cat => cat.Title); } else if (!isDesc && col == "title") { categorySearchResult = categorySearchResult.OrderBy(cat => cat.Title); viewModel.IsDescTitle = true; } else if (isDesc && col == "id") { categorySearchResult = categorySearchResult.OrderByDescending(cat => cat.Id); } else if (!isDesc && col == "id") { categorySearchResult = categorySearchResult.OrderBy(cat => cat.Id); viewModel.IsDescId = true; } return(categorySearchResult); }
public IActionResult RemoveCategoryById(CategoryIndexViewModel model) { _Services.RemoveCategoryPerId(model.Id); return(RedirectToAction("Category", new { id = model.KSIId })); }