public ActionResult DeleteConfirmed(int id) { CommentsOnQuestion commentsOnQuestion = db.CommentsOnQuestions.Find(id); db.CommentsOnQuestions.Remove(commentsOnQuestion); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,QuestionId,Text,Created,UserId")] CommentsOnQuestion commentsOnQuestion) { if (ModelState.IsValid) { db.Entry(commentsOnQuestion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.QuestionId = new SelectList(db.Questions, "Id", "Title", commentsOnQuestion.QuestionId); ViewBag.UserId = new SelectList(db.Users, "Id", "Email", commentsOnQuestion.UserId); return(View(commentsOnQuestion)); }
// GET: CommentsOnQuestions/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CommentsOnQuestion commentsOnQuestion = db.CommentsOnQuestions.Find(id); if (commentsOnQuestion == null) { return(HttpNotFound()); } return(View(commentsOnQuestion)); }
// GET: CommentsOnQuestions/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CommentsOnQuestion commentsOnQuestion = db.CommentsOnQuestions.Find(id); if (commentsOnQuestion == null) { return(HttpNotFound()); } ViewBag.QuestionId = new SelectList(db.Questions, "Id", "Title", commentsOnQuestion.QuestionId); ViewBag.UserId = new SelectList(db.Users, "Id", "Email", commentsOnQuestion.UserId); return(View(commentsOnQuestion)); }
public ActionResult Create([Bind(Include = "Id,Text,Created")] CommentsOnQuestion commentsOnQuestion, int?Qid) { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Questions")); } if (Qid == null) { return(RedirectToAction("Index", "Questions")); } commentsOnQuestion.QuestionId = (int)Qid; commentsOnQuestion.UserId = User.Identity.GetUserId(); commentsOnQuestion.Created = DateTime.Now; if (ModelState.IsValid) { db.CommentsOnQuestions.Add(commentsOnQuestion); db.SaveChanges(); return(RedirectToAction("Index", "Questions")); } ViewBag.QuestionId = new SelectList(db.Questions, "Id", "Title", commentsOnQuestion.QuestionId); ViewBag.UserId = new SelectList(db.Users, "Id", "Email", commentsOnQuestion.UserId); return(View(commentsOnQuestion)); }