public IActionResult Create([Bind("CommentId,ContentComment,PostId")] InsertNewComment comment) { if (ModelState.IsValid) { _unitOfWork.CommentsRepository.InsertComment(comment); return(RedirectToAction(nameof(Index))); } ViewData["PostId"] = new SelectList(_unitOfWork.PostsRepository.GetAllPosts(), "PostId", "Title", comment.PostId); return(View(comment)); }
public void InsertComment(InsertNewComment entity) { Comments Comment = new Comments() { ContentComment = entity.ContentComment, PostId = entity.PostId, CreateDate = entity.CreateDate }; this._DbContext.Comments.Add(Comment); this._DbContext.SaveChanges(); }
public void InsertComment([FromBody] InsertNewComment data) { _unitOfWork.CommentsRepository.InsertComment(data); }