public TotalVotes(Guid userId, int symbolId, int count, VoteDirection myVoteDirection) { UserId = userId; SymbolId = symbolId; Count = count; MyVoteDirection = myVoteDirection; }
public Vote(Guid userId, int symbolId, VoteDirection direction, DateTime lastUpdated) { UserId = userId; SymbolId = symbolId; Direction = direction; LastUpdated = lastUpdated; }
internal Vote(int userId, VotableEntityType resourceType, int resourceId, VoteDirection direction) { UserId = userId; ResourceType = resourceType; ResourceId = resourceId; Direction = direction; }
public async Task <ActionResult> VoteOnComment(int commentId, VoteDirection vote) { var result = await commentVoter.Handle(new VoteOnCommentParams(commentId, vote, User !)); return(result.Match <ActionResult>( vote => Ok(vote), fail => BadRequest(fail) )); }
/// <summary> /// Vote a definiton to be up or down. /// </summary> /// <param name="defId">The definiton id of the... definiton.</param> /// <param name="direction">The direction, either Up or Down</param> /// <returns>When awaited, returns a <see cref="VoteResponse"/>.</returns> /// <exception cref="VoteException"> /// When the <see cref="VoteResponse.Status"/> is <see cref="VoteStatus.Error"/>. /// </exception> public async Task <VoteResponse> VoteOnDefinition(int defId, VoteDirection direction) { CheckDefinitionId(defId); var lowered = direction.ToString().ToLower(); var result = await Rest.ExecuteAsync <VoteResponse>(new RestRequest($"vote?defid={defId}&direction={lowered}")).ConfigureAwait(false); if (result.Status == VoteStatus.Error) { throw new VoteException($"An error occured while sending the vote request, the definiton id ({defId}) is probably wrong."); } return(result); }
/// <summary> /// Add a new vote to the counts. /// </summary> /// <param name="vote">The type of vote to add.</param> public void AddVote(VoteDirection vote) { switch (vote) { case VoteDirection.Up: Upvotes++; break; case VoteDirection.Down: Downvotes++; break; } }
/// <summary> /// Remove a vote from the couns. /// </summary> /// <param name="vote">The vote to remove.</param> public void RemoveVote(VoteDirection vote) { switch (vote) { case VoteDirection.Up: Upvotes--; break; case VoteDirection.Down: Downvotes--; break; } }
public async Task Should_SaveVoteForUser(VoteDirection voteDirection) { string user1Id = (await TestUtil.CreateNewUser(AppTestSettings.Instance.TestDBConnectionString)).ToString(); Symbol jpmSymbol = await _symbolRepo.GetSymbol("JPM"); var voteCommand = new VoteCommand { SymbolId = jpmSymbol.Id, Direction = voteDirection }; await SendVoteForCustomUser(voteCommand, user1Id); Dictionary <int, TotalVotes> voteData = await GetVoteData(user1Id, new int[] { jpmSymbol.Id }); Assert.Single(voteData); Assert.True(voteData.ContainsKey(jpmSymbol.Id)); var totalVotes = voteData[jpmSymbol.Id]; Assert.Equal((int)voteDirection, totalVotes.Count); Assert.Equal(voteDirection, totalVotes.MyVoteDirection); Assert.Equal(jpmSymbol.Id, totalVotes.SymbolId); Assert.Equal(user1Id, totalVotes.UserId.ToString()); }
public Vote CreateForPost(User user, int postId, VoteDirection direction) => new Vote(user.Id, VotableEntityType.Post, postId, direction);
public VoteOnPost(int postId, VoteDirection voteDirection) { PostId = postId; VoteDirection = voteDirection; }
public VoteOnCommentParams(int commentId, VoteDirection vote, User user) { CommentId = commentId; Vote = vote; User = user; }
public VoteOnPostParams(int postId, VoteDirection vote, User user) { PostId = postId; Vote = vote; User = user; }
/// <summary> /// Vote for an image. Send the same value again to undo a vote. /// </summary> /// <param name="albumId">The Id of the album to vote for</param> /// <param name="vote">The vote to give</param> public async Task <ImgurResponse <Boolean> > VoteOnGalleryAlbumAsync(string albumId, VoteDirection vote) { return(await VoteOnGalleryObjectAsync(albumId, true, vote)); }
/// <summary> /// Create a new vote view. /// </summary> /// <param name="resourceType">If its a post or comment.</param> /// <param name="resourceId">The ID of the resource.</param> /// <param name="direction">The direction of the vote.</param> public VoteView(VoteResourceType resourceType, int resourceId, VoteDirection direction) { ResourceType = resourceType; ResourceId = resourceId; Direction = direction; }
/// <summary> /// Vote for an album. Send the same value again to undo a vote. /// </summary> /// <param name="imageId">The Id of the image to vote for</param> /// <param name="vote">The vote to give</param> public async Task <ImgurResponse <Boolean> > VoteOnGalleryImageAsync(string imageId, VoteDirection vote) { return(await VoteOnGalleryObjectAsync(imageId, false, vote)); }
public async Task <IActionResult> VoteOnPost(int postId, VoteDirection vote) => (await mediator.Command(new VoteOnPostCommand(new VoteOnPost(postId, vote), User !)))
public VotePayload(VoteDirection direction, int ratingShift) { this.Direction = direction; this.RatingShift = ratingShift; }
public Vote CreateForComment(User user, int commentId, VoteDirection direction) => new Vote(user.Id, VotableEntityType.Comment, commentId, direction);
public Vote Create(int id, int userId, VotableEntityType entityType, int entityId, VoteDirection direction) => new Vote(id, userId, entityType, entityId, direction);
/// <summary> /// Vote for an item. Send the same value again to undo a vote. /// </summary> /// <param name="ident">The Id of the item to vote for</param> /// <param name="isAlbum">Flags declaring if the item is an album</param> /// <param name="vote">The vote to give</param> private async Task <ImgurResponse <Boolean> > VoteOnGalleryObjectAsync(string ident, bool isAlbum, VoteDirection vote) { if (ImgurClient.Authentication == null) { throw new InvalidAuthenticationException("Authentication can not be null. Set it in the main Imgur class."); } if (!(ImgurClient.Authentication is OAuth2Authentication)) { throw new InvalidAuthenticationException("You need to use OAuth2Authentication to call this Endpoint."); } var endpoint = String.Format(isAlbum ? GalleryVoteAlbumUrl : GalleryVoteImageUrl, ident, vote.ToString().ToLowerInvariant()); return (await Request.SubmitImgurRequestAsync <Boolean>(Request.HttpMethod.Post, endpoint, ImgurClient.Authentication)); }
/// <summary> /// Vote on a comment /// </summary> /// <param name="commentId">The Id of the comment</param> /// <param name="vote">The vote to give the comment</param> public async Task<ImgurResponse<Boolean>> VoteCommentAsync(Int64 commentId, VoteDirection vote) { if (ImgurClient.Authentication == null) throw new InvalidAuthenticationException("Authentication can not be null. Set it in the main Imgur class."); if (!(ImgurClient.Authentication is OAuth2Authentication)) throw new InvalidAuthenticationException("You need to use OAuth2Authentication to call this Endpoint."); return await Request.SubmitImgurRequestAsync<Boolean>(Request.HttpMethod.Get, String.Format(CommentVoteUrl, commentId, vote.ToString().ToLowerInvariant()), ImgurClient.Authentication); }
public VoteOnComment(int commentId, VoteDirection voteDirection) { CommentId = commentId; VoteDirection = voteDirection; }
public async Task <IActionResult> VoteOnComment(int commentId, VoteDirection vote) => (await mediator.Command(new VoteOnCommentCommand(new VoteOnComment(commentId, vote), User !))).Match(
public VotePayload(VoteDirection direction, string steamID, byte[] authTicket) { SteamID = steamID; Ticket = string.Concat(Array.ConvertAll(authTicket, x => x.ToString("X2"))); Direction = ((short)direction).ToString(); }
public Task VoteAsync(VoteDirection vote, int rank, CancellationToken cancellationToken = default(CancellationToken)) { return(Api.PostAsync(UrlConstants.VoteUrl, new { id = FullName, dir = (int)vote, rank }, cancellationToken)); }
public VotePayload(VoteDirection direction, string steamID, string authTicket) { SteamID = steamID; Ticket = authTicket; Direction = ((short)direction).ToString(); }
/// <summary> /// Vote on a comment /// </summary> /// <param name="commentId">The Id of the comment</param> /// <param name="vote">The vote to give the comment</param> public async Task <ImgurResponse <Boolean> > VoteCommentAsync(Int64 commentId, VoteDirection vote) { if (ImgurClient.Authentication == null) { throw new InvalidAuthenticationException("Authentication can not be null. Set it in the main Imgur class."); } if (!(ImgurClient.Authentication is OAuth2Authentication)) { throw new InvalidAuthenticationException("You need to use OAuth2Authentication to call this Endpoint."); } return (await Request.SubmitImgurRequestAsync <Boolean>(Request.HttpMethod.Get, String.Format(CommentVoteUrl, commentId, vote.ToString().ToLowerInvariant()), ImgurClient.Authentication)); }
/// <summary> /// Converts the <see cref="VoteDirection"/> into an emoji /// </summary> /// <param name="direction">The direction (Up,Down) </param> /// <returns>An emoji :D</returns> public static string ToEmoji(this VoteDirection direction) { return(direction == VoteDirection.Up ? "👍" : "👎"); }