Esempio n. 1
0
        public ActionResult NewComment(CommentViewModel model)
        {
            return null;

            string postTitle = _db.GetPostTitle(model.PostId);
            if (ModelState.IsValid)
            {
                CommentBLL commentBLL = CommentBLL.Instance;

                commentBLL.NewComment(model.PostId, model.Name, model.Body, model.Email);

                return RedirectToAction("Post", "Blog", new { UrlTitle = postTitle });
            }
            TempData["CommentModelState"] = model;

            var errors = GetModelStateErrors.GetListOfErrors(ModelState);
            List<string> errorList = errors.Select(err => err.ErrorMessage).ToList();

            TempData["ErrorList"] = errorList;

            return RedirectToAction("Post", "Blog", new { UrlTitle = postTitle });
        }
Esempio n. 2
0
        public ActionResult NewComment(int? postId)
        {
            CommentViewModel viewModel = new CommentViewModel();
            var modelstate = new List<string>();
            if (TempData["CommentModelState"] != null)
            {
                viewModel = (CommentViewModel)TempData["CommentModelState"];
                modelstate = (List<string>)TempData["ErrorList"];

            }
            ViewBag.ViewModel = viewModel;
            ViewBag.postId = postId;

            foreach (var err in modelstate)
            {
                ModelState.AddModelError("", err);
            }

            return View("_PostCommentPartial", viewModel);
        }