public async Task <IActionResult> Items(int feedId, FeedItemsViewModel model) { var query = feedRepository.GetItems(feedId); if (!string.IsNullOrWhiteSpace(model.Search)) { query = query.Where(i => i.Name.Contains(model.Search) || i.Description.Contains(model.Search)); } model.Items = await query .ProjectTo <FeedItemViewModel>(configurationProvider) .OrderByDescending(i => i.CreatedAt) .ToListAsync(); return(View(model)); }
public async Task <IActionResult> Items(int feedId) { var feed = await feedRepository.GetFeedById(feedId); if (feed == null) { this.AddFrontendMessage(Web.ViewModels.Shared.MessageStatus.Danger, "Feed not found"); return(RedirectToAction("Index", "Explore")); } var model = new FeedItemsViewModel(); model.FeedId = feedId; model.FeedName = feed.Name; model.Items = await feedRepository .GetItems(feedId) .ProjectTo <FeedItemViewModel>(configurationProvider) .OrderByDescending(i => i.CreatedAt) .ToListAsync(); return(View(model)); }