Пример #1
0
        public ActionResult PostComment(PostCommentModel model)
        {
            if (ModelState.IsValid)
            {
                // Map model to entity
                Comment comment = GetComment(model);
                commentService.Save(comment);

                // Business Rule:
                // Only syndicate new comment when syndication checkbox is checked
                if (!String.IsNullOrEmpty(model.SyndicationFlag) && model.SyndicationFlag.Equals("1"))
                {
                    PublicCommentEvent(comment);
                }
            }

            return RedirectToAction("Index");
        }
Пример #2
0
 /// <summary>
 /// Map PostCommentModel to a contract entity.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <returns></returns>
 static Comment GetComment(PostCommentModel model)
 {
     Mapper.CreateMap<PostCommentModel, Comment>();
     return Mapper.Map<PostCommentModel, Comment>(model);
 }