예제 #1
0
        public ActionResult Edit(Comment comment)
        {
            comment.DateEdited = DateTime.Now;
            var post = _db.GetPost(comment.PostID);

            if (ModelState.IsValid)
            {
                _db.Edit(comment);
                TempData["MessageEdited"] = "You have saved your post!";
                return(RedirectToAction("Details", new { id = comment.CommentId }));
            }
            var posts = _db.GetAllPosts();

            ViewBag.PostID = new SelectList(posts, "PostId", "Text", post.PostId);
            return(View(comment));
        }