public ActionResult Create(UnComments comment, int?noteid) { ModelState.Remove("CreatedOn"); ModelState.Remove("ModifiedOn"); ModelState.Remove("ModifiedUsername"); if (ModelState.IsValid) { if (noteid == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UnNotes note = noteManager.Find(x => x.Id == noteid); if (note == null) { return(new HttpNotFoundResult()); } comment.Note = note; comment.Owner = SessionManager.User; if (commentManager.Insert(comment) > 0) { return(Json(new { result = true }, JsonRequestBehavior.AllowGet)); } } return(Json(new { result = false }, JsonRequestBehavior.AllowGet)); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UnComments comment = commentManager.Find(x => x.Id == id); if (comment == null) { return(new HttpNotFoundResult()); } if (commentManager.Delete(comment) > 0) { return(Json(new { result = true }, JsonRequestBehavior.AllowGet)); } return(Json(new { result = false }, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(int?id, string text) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UnComments comment = commentManager.Find(x => x.Id == id); if (comment == null) { return(new HttpNotFoundResult()); } comment.Text = text; if (commentManager.Update(comment) > 0) { return(Json(new { result = true }, JsonRequestBehavior.AllowGet)); } return(Json(new { result = false }, JsonRequestBehavior.AllowGet)); }