// GET: Dashboard/NewsItems public async Task <IActionResult> Index( string sortOrder, string currentFilter, string searchString, int?page, bool showDisabled = false) { ViewData["CurrentSort"] = sortOrder; ViewData["NameSortParm"] = string.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; ViewData["DateSortParm"] = sortOrder == "Date" ? "date_desc" : "Date"; ViewData["LastModifiedSortParm"] = sortOrder == "LastModified" ? "last_desc" : "LastModified"; if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewData["CurrentFilter"] = searchString; ViewBag.ShowDisabled = showDisabled; var newsItems = _newsItemRepository.GetAll().Where(n => !n.Deleted && (n.Enabled || showDisabled) && (string.IsNullOrEmpty(searchString) || n.Title.Contains(searchString))); switch (sortOrder) { case "name_desc": newsItems = newsItems.OrderByDescending(c => c.Title); break; case "Date": newsItems = newsItems.OrderBy(c => c.Date); break; case "date_desc": newsItems = newsItems.OrderByDescending(c => c.Date); break; case "LastModified": newsItems = newsItems.OrderBy(c => c.LastModified); break; case "last_desc": newsItems = newsItems.OrderByDescending(c => c.LastModified); break; default: newsItems = newsItems.OrderBy(c => c.Title); break; } return(View(new NewsItemViewModel { NewsItemsList = await PaginatedList <NewsItem> .Create(newsItems, page ?? 1, 5), NewsItemsWithoutTranslation = await _itemTranslationRepository.GetNewsItemsWithoutTranslation() })); }
public IActionResult Index() { var entities = _newsItemRepository.GetAll(); var model = _mapper.Map <List <NewsListItemVM> >(entities); return(View(model)); }
public async Task <IActionResult> Index(int?page) { var language = HttpContext?.Features?.Get <IRequestCultureFeature>()?.RequestCulture?.Culture ?.TwoLetterISOLanguageName ?? "nl"; var newsItems = _newsItemRepository.GetAll().Where(n => n.Enabled && !n.Deleted && n.Language == language).OrderByDescending(n => n.Date); return(View(await PaginatedList <NewsItem> .Create(newsItems, page ?? 1, 12))); }
public IActionResult Index() { var banners = _bannerRepository.GetAll(); var manufacturers = _manufacturerRepository.GetAll(); var news = _newsItemRepository.GetAll().OrderByDescending(x => x.PublishedDate).Take(3); var model = new MainPageVM(); model.Banners = _mapper.Map <List <BannerListItemVM> >(banners); model.Manufacturers = _mapper.Map <List <ManufacturerListItemVM> >(manufacturers); model.News = _mapper.Map <List <NewsListItemVM> >(news); return(View(model)); }