/// <inheritdoc /> public async Task <int> DeleteAsync(ModerationLogChannelMappingSearchCriteria criteria, ulong deletedById) { var entities = await ModixContext.ModerationLogChannelMappings .FilterModerationLogChannelMappingsBy(criteria) .ToArrayAsync(); foreach (var entity in entities) { DoEntityDelete(entity, deletedById); } await ModixContext.SaveChangesAsync(); return(entities.Length); }
/// <inheritdoc /> public Task <bool> AnyAsync(ModerationLogChannelMappingSearchCriteria criteria) => ModixContext.ModerationLogChannelMappings.AsNoTracking() .FilterModerationLogChannelMappingsBy(criteria) .AnyAsync();
/// <inheritdoc /> public async Task <IReadOnlyCollection <ModerationLogChannelMappingBrief> > SearchBriefsAsync(ModerationLogChannelMappingSearchCriteria criteria) => await ModixContext.ModerationLogChannelMappings.AsNoTracking() .FilterModerationLogChannelMappingsBy(criteria) .Select(ModerationLogChannelMappingBrief.FromEntityProjection) .ToArrayAsync();
public static IQueryable <ModerationLogChannelMappingEntity> FilterModerationLogChannelMappingsBy(this IQueryable <ModerationLogChannelMappingEntity> query, ModerationLogChannelMappingSearchCriteria criteria) { var longGuildId = (long?)criteria?.GuildId; var longLogChannelId = (long?)criteria?.LogChannelId; var longCreatedById = (long?)criteria?.CreatedById; return(query .FilterBy( x => x.GuildId == longGuildId, longGuildId != null) .FilterBy( x => x.LogChannelId == longLogChannelId, longLogChannelId != null) .FilterBy( x => x.CreateAction.Created >= criteria.CreatedRange.Value.From, criteria?.CreatedRange?.From != null) .FilterBy( x => x.CreateAction.Created <= criteria.CreatedRange.Value.To, criteria?.CreatedRange?.To != null) .FilterBy( x => x.CreateAction.CreatedById == longCreatedById, longCreatedById != null) .FilterBy( x => (x.DeleteActionId != null) == criteria.IsDeleted, criteria?.IsDeleted != null)); }