public ActionResult AddTagToPost(AddTagToPost model) { var tag = db.Tags.Find(model.selectedTag); var post = db.Posts.Find(model.selectedPost); post.Tags.Add(tag); db.SaveChanges(); return(RedirectToAction("Details/" + post.Id)); }
public ActionResult AddTagToPost(int id) { AddTagToPost model = new AddTagToPost(); model.selectedPost = id; model.tags = db.Tags.ToList(); ViewBag.PostTitle = db.Posts.Find(id).Title; return(View(model)); }