public ActionResult Tag(int?id) { var tags = db.Tags.Include(t => t.Posts.Select(p => p.Author)).ToList(); var tag = tags.FirstOrDefault(t => t.Id == id); if (tag == null) { return(HttpNotFound()); } var posts = tag.Posts.ToList(); var images = db.Images.ToList(); foreach (var post in posts) { post.SetImage(images); } ViewBag.Header = tag.Name; TagsIndexViewModel viewModel = new TagsIndexViewModel { Posts = posts, PopularTags = tags.OrderByDescending(t => t.Posts.Count).Take(5).ToList() }; return(View(viewModel)); }
public ActionResult Index() { var tags = _tagService.GetTags(); var model = new TagsIndexViewModel { Tags = tags.ToList() }; return(View(model)); }
public IActionResult Index(string name) { var entities = this.weetsService.GetAllByTagId <FullWeetViewModel>(name); var model = new TagsIndexViewModel() { TagName = name, Weets = entities.ToList() }; return(this.View(model)); }