public async Task <IActionResult> SavePostComment(SaveCommentModel commentModel) { try { var model = await _loader.GetPostAsync <StandardPost>(commentModel.Id, HttpContext.User); // Create the comment var comment = new Comment { IpAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString(), UserAgent = Request.Headers.ContainsKey("User-Agent") ? Request.Headers["User-Agent"].ToString() : "", Author = commentModel.CommentAuthor, Email = commentModel.CommentEmail, Url = commentModel.CommentUrl, Body = commentModel.CommentBody }; await _api.Posts.SaveCommentAndVerifyAsync(commentModel.Id, comment); return(Redirect(model.Permalink + "#comments")); } catch (UnauthorizedAccessException) { return(Unauthorized()); } }
public async Task UpdateAsync(Guid commentId, SaveCommentModel saveCommentModel) { var updateCommentModel = new UpdateCommentModel { Id = commentId, Content = saveCommentModel.Content }; await _commentManager.UpdateCommentAsync(updateCommentModel); }
public async Task <Guid> AddCommentAsync(Guid postId, SaveCommentModel model) { ArgumentGuard.NotEmpty(postId, nameof(postId)); ArgumentGuard.NotNull(model, nameof(model)); var post = await _postService.GetPostAsync(postId); // permission return(await _commentService.AddCommentAsync(post.Id, model)); }
public ActionResult SaveComment(Comment comment, int mediaItemId, [FromServices] SaveCommentCommand saveCommentCmd) { var model = new SaveCommentModel(); model.mediaItemId = mediaItemId; model.comment = comment; model.User = User; if (!ModelState.IsValid) { var item = LoadMediaItem(mediaItemId); return(View("Picture", item)); } saveCommentCmd.Execute(model); return(RedirectToAction("Details", new { id = mediaItemId })); }
public async Task <Guid> AddCommentAsync(Guid postId, SaveCommentModel model) { ArgumentGuard.NotEmpty(postId, nameof(postId)); ArgumentGuard.NotNull(model, nameof(model)); await _validatorFactory.ValidateAsync(model); var commentEntity = new CommentEntity { Id = Guid.NewGuid(), Content = model.Content, AuthorId = _userContext.UserId, PostId = postId, CreatedDateUtc = DateTime.UtcNow, LastModfiedById = _userContext.UserId, }; return(await _commentRepository.AddAsync(commentEntity)); }
public Task UpdateComment(Guid commentId, [FromBody] SaveCommentModel model) { return(_commentManager.AddCommentAsync(commentId, model)); }
public Task <Guid> AddComment(Guid postId, [FromBody] SaveCommentModel model) { return(_commentManager.AddCommentAsync(postId, model)); }