public ActionResult DeleteComment(int id, int redirect) { NoticeComment mycomment = followPeersDB.NoticeComments.SingleOrDefault(p => p.NoticeCommentId == id); string message = mycomment.message; followPeersDB.NoticeComments.Remove(mycomment); followPeersDB.Entry(mycomment).State = EntityState.Deleted; followPeersDB.SaveChanges(); //Delete the update as well Update myupdate = followPeersDB.Updates.SingleOrDefault(p => p.message == message && p.Own == true); followPeersDB.Updates.Remove(myupdate); followPeersDB.Entry(myupdate).State = EntityState.Deleted; followPeersDB.SaveChanges(); return(RedirectToAction("Index", "Notice", new { id = redirect })); }
public ActionResult SubmitComment(int noticeId, string comment) { NoticeComment noticeComment = new NoticeComment { // ************************************************************************** CHANGE LATER EmployeeId = 1, EmployeeName = "tEST eMPLOYEE", // ************************************************************************** CHANGE LATER NoticeId = noticeId, Comment = comment }; CommentService.Insert(noticeComment); return(RedirectToAction("Details", new { id = noticeId })); }
public ActionResult Details(NoticeComment noticeComment) { if (noticeComment.Comment != null) { noticeComment.EmployeeId = Int32.Parse(Session["Id"].ToString()); noticeComment.EmployeeName = Session["Name"].ToString(); if (Debugger.IsAttached) { Output.Write("Inside Notice comment section"); Output.Write("noticeComment contains: " + noticeComment.Comment + " : " + noticeComment.NoticeId + " : " + noticeComment.EmployeeName); } CommentService.Insert(noticeComment); } return(RedirectToAction("Details", noticeComment.NoticeId)); }