コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            CommentOnAnswer commentOnAnswer = db.CommentOnAnswers.Find(id);

            db.CommentOnAnswers.Remove(commentOnAnswer);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
 public ActionResult Edit([Bind(Include = "Id,AnswerId,Text,Created,UserId")] CommentOnAnswer commentOnAnswer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(commentOnAnswer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AnswerId = new SelectList(db.Answers, "Id", "Text", commentOnAnswer.AnswerId);
     ViewBag.UserId   = new SelectList(db.Users, "Id", "Email", commentOnAnswer.UserId);
     return(View(commentOnAnswer));
 }
コード例 #3
0
        // GET: CommentOnAnswers/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CommentOnAnswer commentOnAnswer = db.CommentOnAnswers.Find(id);

            if (commentOnAnswer == null)
            {
                return(HttpNotFound());
            }
            return(View(commentOnAnswer));
        }
コード例 #4
0
        // GET: CommentOnAnswers/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CommentOnAnswer commentOnAnswer = db.CommentOnAnswers.Find(id);

            if (commentOnAnswer == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AnswerId = new SelectList(db.Answers, "Id", "Text", commentOnAnswer.AnswerId);
            ViewBag.UserId   = new SelectList(db.Users, "Id", "Email", commentOnAnswer.UserId);
            return(View(commentOnAnswer));
        }
コード例 #5
0
        public ActionResult Create([Bind(Include = "Id,Text,Created")] CommentOnAnswer commentOnAnswer, int?Aid)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Index", "Questions"));
            }
            if (Aid == null)
            {
                return(RedirectToAction("Index", "Questions"));
            }
            commentOnAnswer.AnswerId = (int)Aid;
            commentOnAnswer.UserId   = User.Identity.GetUserId();
            commentOnAnswer.Created  = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.CommentOnAnswers.Add(commentOnAnswer);
                db.SaveChanges();
                return(RedirectToAction("Index", "Questions"));
            }

            ViewBag.AnswerId = new SelectList(db.Answers, "Id", "Text", commentOnAnswer.AnswerId);
            ViewBag.UserId   = new SelectList(db.Users, "Id", "Email", commentOnAnswer.UserId);
            return(View(commentOnAnswer));
        }