Ejemplo n.º 1
0
 private async Task <IVoteable> GetVoteableFromRepositoryAsync(VoteTargetEnum voteTarget, Guid voteTargetId)
 {
     return(voteTarget switch
     {
         VoteTargetEnum.Question => _ = await _questionRepository.GetByIdAsync(voteTargetId),
         VoteTargetEnum.Answer => _ = await _answerRepository.GetByIdAsync(voteTargetId),
         VoteTargetEnum.Comment => _ = await _commentRepository.GetByIdAsync(voteTargetId),
         _ => throw new ArgumentException()
     });
Ejemplo n.º 2
0
 public async Task <int> GetVotesSumAsync(Guid targetId, VoteTargetEnum voteTarget) =>
 await _cache.GetOrCreateConcurrentAsync(
     GetCachingKey(new VoteCachingContext(targetId, voteTarget)),
     () => _voteRepository.GetVotesSumAsync(targetId),
     60);
Ejemplo n.º 3
0
 public VoteCachingContext(Guid targetId, VoteTargetEnum target)
 {
     TargetId = targetId;
     Target   = target;
 }
Ejemplo n.º 4
0
 private VoteTargets(string name, VoteTargetEnum target)
 {
     Name   = name;
     Target = target;
 }