public ActionResult AddComment(Comment comment, int PostID) { if (ModelState.IsValid) { string BlogPostJsonPath = Server.MapPath("~/App_Data/Blog-Posts.json"); comment.date = DateTime.Now; _blogPostService.AddComment(comment, PostID, BlogPostJsonPath); } return(RedirectToAction("Post", new { id = PostID })); }
public async Task <IActionResult> BlogPostDetail([FromForm] BlogPostDetailViewModel model) { if (ModelState.IsValid) { // map dto to entity var blogPostCommentDto = _mapper.Map <BlogPostCommentDto>(model); // save await _blogPostService.AddComment(blogPostCommentDto); return(RedirectToAction("BlogPostDetail", new { blogPostId = model.Id })); } return(View(model)); }