public void PostComment(PostedCommentDTO postedCommentDTO) { var config = new MapperConfiguration(cfg => cfg.CreateMap <PostedCommentDTO, PostedComment>()); var mapper = config.CreateMapper(); PostedComment postedComment = mapper.Map <PostedCommentDTO, PostedComment>(postedCommentDTO); postedComment.CreatedOn = DateTime.Now; postedComment.ModifiedOn = DateTime.Now; PostedCommentRepository.Add(postedComment); }
public ActionResult PostComment([Bind(Include = "ID,Comments")] BookReadingEventDetailsViewModel bookReadingEventDetailsViewModel) { try { if (ModelState.IsValid) { PostedCommentDTO postedCommentDTO = new PostedCommentDTO(); postedCommentDTO.BookReadingEventID = bookReadingEventDetailsViewModel.ID; postedCommentDTO.Comments = bookReadingEventDetailsViewModel.Comments; postedCommentDTO.EmailID = Session["emailID"].ToString(); BusinessLayerPostedComments.PostComment(postedCommentDTO); return(RedirectToAction("GetBookReadingEventDetails", new { id = bookReadingEventDetailsViewModel.ID })); } } catch (DataBaseUpdationException exception) { return(Content(exception.Message)); } return(View()); }