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() });
public async Task <int> GetVotesSumAsync(Guid targetId, VoteTargetEnum voteTarget) => await _cache.GetOrCreateConcurrentAsync( GetCachingKey(new VoteCachingContext(targetId, voteTarget)), () => _voteRepository.GetVotesSumAsync(targetId), 60);
public VoteCachingContext(Guid targetId, VoteTargetEnum target) { TargetId = targetId; Target = target; }
private VoteTargets(string name, VoteTargetEnum target) { Name = name; Target = target; }