Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
 public void InsertComment([FromBody] InsertNewComment data)
 {
     _unitOfWork.CommentsRepository.InsertComment(data);
 }