public bool editComment(Comment edited) { Comment c = getCommentByID(edited.ID); if (c != null) { c.Body = edited.Body; c.DateInserted = edited.DateInserted; return db.SaveChanges() != 0; } return false; }
public ActionResult CreateComment(FormCollection collection) { Comment c = new Comment(); c.Body = collection["commentText"]; c.DateInserted = DateTime.Now; c.UserID = User.Identity.GetUserId(); c.UserName = User.Identity.Name; c.StatusID = Convert.ToInt32(collection["statusID"]); c.CurrentLogedinUser = User.Identity.GetUserId(); var status = statusService.getStatusByID(c.StatusID); c.StatusUserID = status.UserID; statusService.addComment(c); string url = this.Request.UrlReferrer.AbsoluteUri; return Redirect(url); }
public ActionResult EditComment(FormCollection collection) { int? id = Convert.ToInt32(collection["commentId"]); Comment currentComment = statusService.getCommentByID(id); Comment editComment = new Comment(); editComment.ID = currentComment.ID; editComment.DateInserted = currentComment.DateInserted; editComment.Body = null; editComment.StatusUserID = currentComment.StatusUserID; editComment.CurrentLogedinUser = User.Identity.GetUserId(); string commentTextboxId = "commentTextbox" + Convert.ToString(id); if (currentComment.Body != null) { editComment.Body = collection[commentTextboxId]; } statusService.editComment(editComment); string url = this.Request.UrlReferrer.AbsoluteUri; return Redirect(url); }
public bool addComment(Comment toAdd) { db.Comments.Add(toAdd); return db.SaveChanges() != 0; }
public bool removeComment(Comment toDel) { db.Comments.Remove(toDel); return db.SaveChanges() != 0; }