async Task <int> IVoteRepository.DeleteAsync(NanokaEntity entity, string entityId, CancellationToken cancellationToken)
        {
            var deleted = await DeleteAsync <DbVote>(
                q => q.Query(qq => qq.Bool(b => b.Filter(f => f.Term(t => t.Field(v => v.EntityType)
                                                                     .Value(entity)),
                                                         f => f.Term(t => t.Field(v => v.EntityId)
                                                                     .Value(entityId))))),
                cancellationToken);

            return(deleted);
        }
 async Task <Vote> IVoteRepository.GetAsync(string userId, NanokaEntity entity, string entityId, CancellationToken cancellationToken)
 => (await GetAsync <DbVote>(DbVote.CreateId(userId, entity, entityId), cancellationToken))?.ToVote();
Beispiel #3
0
 public static string CreateId(string userId, NanokaEntity entity, string entityId)
 => $"{userId}_{ExtensionsEnum<NanokaEntity>.GetName(entity)}_{entityId}";