mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
inject AM IConfigurationProvider rather than IMapper
This commit is contained in:
parent
4eb9b1273e
commit
812ceed175
4 changed files with 15 additions and 12 deletions
|
|
@ -12,15 +12,16 @@ namespace FilterLists.Services.FilterList
|
|||
[UsedImplicitly]
|
||||
public class FilterListService : Service
|
||||
{
|
||||
public FilterListService(FilterListsDbContext dbContext, IMapper mapper) : base(dbContext, mapper)
|
||||
public FilterListService(FilterListsDbContext dbContext, IConfigurationProvider configurationProvider) :
|
||||
base(dbContext, configurationProvider)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ListSummaryDto>> GetAllSummariesAsync() =>
|
||||
await DbContext.FilterLists.ProjectTo<ListSummaryDto>(Mapper.ConfigurationProvider).ToListAsync();
|
||||
await DbContext.FilterLists.ProjectTo<ListSummaryDto>(ConfigurationProvider).ToListAsync();
|
||||
|
||||
public async Task<ListDetailsDto> GetDetailsAsync(uint id) =>
|
||||
await DbContext.FilterLists.ProjectTo<ListDetailsDto>(Mapper.ConfigurationProvider)
|
||||
await DbContext.FilterLists.ProjectTo<ListDetailsDto>(ConfigurationProvider)
|
||||
.FirstOrDefaultAsync(x => x.Id == id)
|
||||
.FilterParentListFromMaintainerAdditionalLists();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,18 +13,19 @@ namespace FilterLists.Services.Seed
|
|||
[UsedImplicitly]
|
||||
public class SeedService : Service
|
||||
{
|
||||
public SeedService(FilterListsDbContext dbContext, IMapper mapper) : base(dbContext, mapper)
|
||||
public SeedService(FilterListsDbContext dbContext, IConfigurationProvider configurationProvider)
|
||||
: base(dbContext, configurationProvider)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TSeedDto>> GetAllAsync<TEntity, TSeedDto>() where TEntity : class =>
|
||||
await DbContext.Set<TEntity>().ProjectTo<TSeedDto>(Mapper.ConfigurationProvider).ToArrayAsync();
|
||||
await DbContext.Set<TEntity>().ProjectTo<TSeedDto>(ConfigurationProvider).ToArrayAsync();
|
||||
|
||||
public async Task<IEnumerable<TSeedDto>> GetAllAsync<TEntity, TSeedDto>(PropertyInfo primarySort)
|
||||
where TEntity : class =>
|
||||
await DbContext.Set<TEntity>()
|
||||
.OrderBy(x => primarySort.GetValue(x, null))
|
||||
.ProjectTo<TSeedDto>(Mapper.ConfigurationProvider)
|
||||
.ProjectTo<TSeedDto>(ConfigurationProvider)
|
||||
.ToArrayAsync();
|
||||
|
||||
public async Task<IEnumerable<TSeedDto>> GetAllAsync<TEntity, TSeedDto>(PropertyInfo primarySort,
|
||||
|
|
@ -32,7 +33,7 @@ public async Task<IEnumerable<TSeedDto>> GetAllAsync<TEntity, TSeedDto>(Property
|
|||
await DbContext.Set<TEntity>()
|
||||
.OrderBy(x => primarySort.GetValue(x, null))
|
||||
.ThenBy(x => secondarySort.GetValue(x, null))
|
||||
.ProjectTo<TSeedDto>(Mapper.ConfigurationProvider)
|
||||
.ProjectTo<TSeedDto>(ConfigurationProvider)
|
||||
.ToArrayAsync();
|
||||
}
|
||||
}
|
||||
|
|
@ -7,15 +7,15 @@ namespace FilterLists.Services
|
|||
[UsedImplicitly]
|
||||
public class Service
|
||||
{
|
||||
protected readonly IConfigurationProvider ConfigurationProvider;
|
||||
protected readonly FilterListsDbContext DbContext;
|
||||
protected readonly IMapper Mapper;
|
||||
|
||||
public Service(FilterListsDbContext dbContext) => DbContext = dbContext;
|
||||
|
||||
public Service(FilterListsDbContext dbContext, IMapper mapper)
|
||||
public Service(FilterListsDbContext dbContext, IConfigurationProvider configurationProvider)
|
||||
{
|
||||
DbContext = dbContext;
|
||||
Mapper = mapper;
|
||||
ConfigurationProvider = configurationProvider;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,8 @@ public class SnapshotService : Service
|
|||
private static readonly IList<uint> IgnoreLists =
|
||||
new ReadOnlyCollection<uint>(new List<uint> {48, 149, 173, 185, 186, 187, 188, 189, 352});
|
||||
|
||||
public SnapshotService(FilterListsDbContext dbContext, IMapper mapper) : base(dbContext, mapper)
|
||||
public SnapshotService(FilterListsDbContext dbContext, IConfigurationProvider configurationProvider)
|
||||
: base(dbContext, configurationProvider)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -49,7 +50,7 @@ await DbContext
|
|||
.ThenBy(list =>
|
||||
list.Snapshots.Select(ss => ss.CreatedDateUtc).OrderByDescending(sscd => sscd).FirstOrDefault())
|
||||
.Take(batchSize)
|
||||
.ProjectTo<FilterListViewUrlDto>(Mapper.ConfigurationProvider)
|
||||
.ProjectTo<FilterListViewUrlDto>(ConfigurationProvider)
|
||||
.ToListAsync();
|
||||
|
||||
private IEnumerable<SnapshotDe> GetSnapshots(IEnumerable<FilterListViewUrlDto> lists) =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue