public async Task <IActionResult> AddComment(ActionApiModel model) { model.Comment.Created = DateTime.Now; var count = await _blogService.AddComment(model.BlogId, model.Comment); return(Ok(count)); }
public async Task AddCommentTest() { var comment = new AddCommentRequest(0, "mikke", "Ei vttu, et o tosissas?!"); await _service.AddComment(comment); Assert.AreEqual(1, _blog.Comments.Count); }
public async Task <ActionResult> AddComment(AddCommentViewModel vm) { if (!ModelState.IsValid) { throw new Exception("Don't be daft, fill in the comment"); } var user = User?.Identity?.Name; var request = new AddCommentRequest(vm.Id, user, vm.Comment); await _blogService.AddComment(request); var model = new CommentViewModel(user, DateTime.Now, vm.Comment); return(PartialView(model)); }
public async Task <ActionResult> AddComment(string postId, string comment, string url) { if (ModelState.IsValid) { var currentUser = User.Identity; CommentDto commentDto = new CommentDto { Text = comment, CreateAt = DateTime.Now, UserProfileId = currentUser.GetUserId(), UserEmail = currentUser.Name, PostId = Int32.Parse(postId), IsDeleted = false }; await BlogService.AddComment(commentDto); } return(Redirect(url)); }
public async Task AddComment([FromBody] AddCommentRequest request) { await _blogService.AddComment(request); }