Exemplo n.º 1
0
 private async Task InsertNewVoteAsync(int direction, PublicProfile profile, int ideaId)
 {
     var vote = new ProductIdeaVote
     {
         Direction     = direction,
         Issuer        = profile,
         ProductIdeaId = ideaId
     };
     await _context.ProductIdeaVotes.AddAsync(vote);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Replaces the existing vote, or deletes it if direction == 0
 /// </summary>
 /// <param name="direction">The vote direction</param>
 /// <param name="existingVote">The existing vote</param>
 /// <returns>Whether ot not the vote has been replaced or deleted</returns>
 private bool TryReplaceExistingVote(int direction, ProductIdeaVote existingVote)
 {
     if (existingVote.Direction == direction)
     {
         _context.ProductIdeaVotes.Remove(existingVote);
         return(false);
     }
     else
     {
         _context.Attach(existingVote);
         existingVote.Direction = direction;
         return(true);
     }
 }