mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
filter non-implemented from endpoints
This commit is contained in:
parent
b9cb2c4e7e
commit
5fca7674db
7 changed files with 39 additions and 32 deletions
|
|
@ -19,12 +19,12 @@ public MaintainersController(IMemoryCache memoryCache, SeedService seedService,
|
|||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll() =>
|
||||
await Get(() => maintainerService.GetAllAsync());
|
||||
await Get(() => maintainerService.GetAllThatMaintainAnyListAsync());
|
||||
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<IActionResult> GetById(int id) =>
|
||||
await Get(() => maintainerService.GetByIdAsync(id), id);
|
||||
await Get(() => maintainerService.GetIfMaintainsAnyListByIdAsync(id), id);
|
||||
|
||||
[HttpGet("seed")]
|
||||
public async Task<IActionResult> Seed() =>
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@ public SyntaxesController(IMemoryCache memoryCache, SeedService seedService, Syn
|
|||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll() =>
|
||||
await Get(() => syntaxService.GetAll());
|
||||
await Get(() => syntaxService.GetAllImplemented());
|
||||
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<IActionResult> GetById(int id) =>
|
||||
await Get(() => syntaxService.GetById(id), id);
|
||||
await Get(() => syntaxService.GetImplementedById(id), id);
|
||||
|
||||
[HttpGet("seed")]
|
||||
public async Task<IActionResult> Seed() =>
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@ public TagsController(IMemoryCache memoryCache, SeedService seedService, TagServ
|
|||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll() =>
|
||||
await Get(() => tagService.GetAll());
|
||||
await Get(() => tagService.GetAllImplemented());
|
||||
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<IActionResult> GetById(int id) =>
|
||||
await Get(() => tagService.GetById(id), id);
|
||||
await Get(() => tagService.GetImplementedById(id), id);
|
||||
|
||||
[HttpGet("seed")]
|
||||
public async Task<IActionResult> Seed() =>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
|
|
@ -17,14 +18,15 @@ public MaintainerService(FilterListsDbContext dbContext, IConfigurationProvider
|
|||
{
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<MaintainerDto>> GetAllAsync() =>
|
||||
await DbContext.Maintainers
|
||||
.ProjectTo<MaintainerDto>(MapConfig)
|
||||
.ToListAsync();
|
||||
private IQueryable<Data.Entities.Maintainer> MaintainsAnyLists =>
|
||||
DbContext.Maintainers.Where(m => m.FilterListMaintainers.Any());
|
||||
|
||||
public async Task<MaintainerDto> GetByIdAsync(int id) =>
|
||||
await DbContext.Maintainers
|
||||
.ProjectTo<MaintainerDto>(MapConfig)
|
||||
.FirstOrDefaultAsync(m => m.Id == id);
|
||||
public async Task<IEnumerable<MaintainerDto>> GetAllThatMaintainAnyListAsync() =>
|
||||
await MaintainsAnyLists.ProjectTo<MaintainerDto>(MapConfig)
|
||||
.ToListAsync();
|
||||
|
||||
public async Task<MaintainerDto> GetIfMaintainsAnyListByIdAsync(int id) =>
|
||||
await MaintainsAnyLists.ProjectTo<MaintainerDto>(MapConfig)
|
||||
.FirstOrDefaultAsync(m => m.Id == id);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Data;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
|
@ -13,6 +14,6 @@ public RuleService(FilterListsDbContext dbContext) : base(dbContext)
|
|||
}
|
||||
|
||||
public async Task<int> GetCountAll() =>
|
||||
await DbContext.Rules.AsNoTracking().CountAsync();
|
||||
await DbContext.Rules.AsNoTracking().Where(r => r.SnapshotRules.Any()).CountAsync();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
|
|
@ -17,14 +18,15 @@ public SyntaxService(FilterListsDbContext dbContext, IConfigurationProvider mapC
|
|||
{
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SyntaxDto>> GetAll() =>
|
||||
await DbContext.Syntaxes
|
||||
.ProjectTo<SyntaxDto>(MapConfig)
|
||||
.ToListAsync();
|
||||
private IQueryable<Data.Entities.Syntax> ImplementedSyntaxes =>
|
||||
DbContext.Syntaxes.Where(s => s.FilterLists.Any());
|
||||
|
||||
public async Task<SyntaxDto> GetById(int id) =>
|
||||
await DbContext.Syntaxes
|
||||
.ProjectTo<SyntaxDto>(MapConfig)
|
||||
.FirstOrDefaultAsync(s => s.Id == id);
|
||||
public async Task<IEnumerable<SyntaxDto>> GetAllImplemented() =>
|
||||
await ImplementedSyntaxes.ProjectTo<SyntaxDto>(MapConfig)
|
||||
.ToListAsync();
|
||||
|
||||
public async Task<SyntaxDto> GetImplementedById(int id) =>
|
||||
await ImplementedSyntaxes.ProjectTo<SyntaxDto>(MapConfig)
|
||||
.FirstOrDefaultAsync(s => s.Id == id);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
|
|
@ -17,14 +18,15 @@ public TagService(FilterListsDbContext dbContext, IConfigurationProvider mapConf
|
|||
{
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TagDto>> GetAll() =>
|
||||
await DbContext.Tags
|
||||
.ProjectTo<TagDto>(MapConfig)
|
||||
.ToListAsync();
|
||||
private IQueryable<Data.Entities.Tag> ImplementedTags =>
|
||||
DbContext.Tags.Where(t => t.FilterListTags.Any());
|
||||
|
||||
public async Task<TagDto> GetById(int id) =>
|
||||
await DbContext.Tags
|
||||
.ProjectTo<TagDto>(MapConfig)
|
||||
.FirstOrDefaultAsync(t => t.Id == id);
|
||||
public async Task<IEnumerable<TagDto>> GetAllImplemented() =>
|
||||
await ImplementedTags.ProjectTo<TagDto>(MapConfig)
|
||||
.ToListAsync();
|
||||
|
||||
public async Task<TagDto> GetImplementedById(int id) =>
|
||||
await ImplementedTags.ProjectTo<TagDto>(MapConfig)
|
||||
.FirstOrDefaultAsync(t => t.Id == id);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue