public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tag tag = db.GetTagById(User, id.Value); if (tag == null) { return(HttpNotFound()); } return(View(tag)); }
// GET: /Task/AddTag/5?tagid=1 public ActionResult AddTag(int?id, int?tagid) { if (id == null || tagid == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var task = db.GetTaskById(User, id.Value); var tag = db.GetTagById(User, tagid.Value); if (task == null || tag == null) { return(HttpNotFound()); } if (task.Tags.Where(t => t.ID == tag.ID).FirstOrDefault() == null) { task.Tags.Add(tag); } db.SaveChanges(); return(Redirect(Request.GetReferrerUrlOrCurrent())); }