public ActionResult AddComment(Comment comment) { CommentDAO dao = new CommentDAO(); if (string.IsNullOrEmpty(comment.Name)) { ModelState.AddModelError("Name", "Нет вашего имени!"); } if (string.IsNullOrEmpty(comment.Email)) { ModelState.AddModelError("Email", "Нет вашего email!"); } if (string.IsNullOrEmpty(comment.Body)) { ModelState.AddModelError("Body", "Нет вашего сообщения!"); } if (ModelState.IsValid) { Comment newComment = new Comment() { Name = comment.Name, Body = comment.Body, Email = comment.Email, Date = DateTime.Now.Date }; dao.AddComment(newComment); return(RedirectToAction("AddComment")); } else { var listComment = dao.GetListComment(); return(View(listComment)); } }
public ActionResult AddComment() { CommentDAO dao = new CommentDAO(); var listComment = dao.GetListComment(); return(View(listComment)); }