public async Task <ActionResult <PostVoteDTO> > AddVote(PostVoteDTO newVote) { var user = await userFinder.FindByClaimsPrincipal(User); newVote.UserId = user.Id; newVote = await postManager.AddVote(newVote); if (newVote == null) { return(NotFound()); } await postNotifier.SendUpdate(newVote.PostId); return(Ok()); }
public async Task <ActionResult <CommentDTO> > Add(CommentDTO newComment) { var user = await userFinder.FindByClaimsPrincipal(User); if (user == null) { return(Unauthorized()); } if (newComment.PostId == 0) { return(BadRequest()); } newComment.AuthorId = user.Id; var added = await commentDTOManager.Add(newComment); if (added == null) { return(BadRequest()); } await postNotifier.SendUpdate(newComment.PostId); return(CreatedAtAction(nameof(GetSingle), new { id = added.Id }, added)); }