예제 #1
0
 public ActionResult Form(long newsId)
 {
     var model = new CommentAddOrUpdateViewModel
     {
         ArticleId = newsId,
     };
     return PartialView("Form", model);
 }
예제 #2
0
        public ActionResult Form(CommentAddOrUpdateViewModel model)
        {
            if (!ValidateRecaptcha())
            {
                ModelState.AddModelError("reCaptcha", "reCaptcha didn't go as expected.");
            }

            if (ModelState.IsValid)
            {
                var added = _commentsService.AddOrUpdate(model);
                if (added)
                {
                    return ForNews(model.ArticleId);
                }
            }

            return PartialView(model);
        }
예제 #3
0
 public static Comment MapToModel(this CommentAddOrUpdateViewModel vm)
 {
     return(Mapper.Map <Comment>(vm));
 }