public ActionResult DeleteConfirmed(int id) { Comment_Tbl comment_Tbl = db.Comment_Tbl.Find(id); db.Comment_Tbl.Remove(comment_Tbl); db.SaveChanges(); ViewData["ED"] = "Successfully deleted"; return(View("Index", db.Comment_Tbl.Where(x => x.PostId == comment_Tbl.PostId))); }
public ActionResult Edit([Bind(Include = "CommentId,UserId,PostId,Name,Date")] Comment_Tbl comment_Tbl) { if (comment_Tbl.Name != null) { if (ModelState.IsValid) { db.Entry(comment_Tbl).State = EntityState.Modified; db.SaveChanges(); ViewData["ED"] = "Successfully edited"; return(View("Index", db.Comment_Tbl.Where(x => x.PostId == comment_Tbl.PostId))); } return(View(comment_Tbl)); } ViewData["ED"] = "Write something"; return(View(comment_Tbl)); }
// GET: Comment_Tbl/Edit/5 public ActionResult Edit(int?id) { if (Session["id"] != null) { c = db.Comment_Tbl.Find(id); u = db.Users_Tbl.Find(Session["id"]); if (c.UserId == u.UserId || u.RollId == 1) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Comment_Tbl comment_Tbl = db.Comment_Tbl.Find(id); if (comment_Tbl == null) { return(HttpNotFound()); } return(View(comment_Tbl)); } return(RedirectToAction("index", new { id = c.PostId })); } return(RedirectToAction("index", new { id = c.PostId })); }