public ActionResult AddComment(AddCommentViewModel model)
 {
     if (ModelState.IsValid)
     {
         _postRepository.AddComment(model);
     }
     return(RedirectToAction("SinglePost", "Post", new { id = model.PostId }));
 }
Beispiel #2
0
 public HttpStatusCode Create(Comment comment)
 {
     if (ModelState.IsValid)
     {
         _repository.AddComment(comment);
         return(HttpStatusCode.Created);
     }
     return(HttpStatusCode.BadRequest);
 }
Beispiel #3
0
 public ActionResult PostComment([Bind(Exclude = "Id")] CommentVM comment)
 {
     if (ModelState.IsValid)
     {
         var newcommentdata = Mapper.Map <CommentVM, Comment>(comment);
         newcommentdata.CommentedDate = DateTime.Now;
         _blogRepository.AddComment(newcommentdata);
         return(RedirectToAction("Detail", new { blogId = comment.BlogId }));
     }
     return(View());
 }
        public ActionResult CreateComment(long id, Comment comment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(comment));
            }

            Post post = blogRepository.GetById(id);

            if (post != null)
            {
                blogRepository.AddComment(post, comment);
                return(Ok());
            }

            return(NotFound(id));
        }
Beispiel #5
0
 public async Task AddComment(AddCommentRequest request)
 {
     var comment = _mapper.Map <AddCommentRequest, Comment>(request);
     await _repository.AddComment(comment);
 }
Beispiel #6
0
        public async Task <long> AddComment(string blogId, CommentEntity comment)
        {
            var model = _mapper.Map <CommentModel>(comment);

            return(await _blogRepository.AddComment(blogId, model));
        }
Beispiel #7
0
 public JsonCamelCaseResult Add(Comment comment)
 {
     _blogRepository.AddComment(comment);
     return(new JsonCamelCaseResult("Add success"));
 }
 public IActionResult AddComment(Comment comment, Guid postId)
 {
     repository.AddComment(comment, postId);
     return(RedirectToAction(nameof(Post), new { id = repository.Get(postId).Id }));
 }