mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
filter licenses by implemented
This commit is contained in:
parent
be29d16eb3
commit
b9cb2c4e7e
2 changed files with 12 additions and 10 deletions
|
|
@ -18,12 +18,12 @@ public LicensesController(IMemoryCache memoryCache, SeedService seedService, Lic
|
|||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll() =>
|
||||
await Get(() => licenseService.GetAllAsync());
|
||||
await Get(() => licenseService.GetAllImplementedAsync());
|
||||
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<IActionResult> GetById(int id) =>
|
||||
await Get(() => licenseService.GetByIdAsync(id), id);
|
||||
await Get(() => licenseService.GetImplementedByIdAsync(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 LicenseService(FilterListsDbContext dbContext, IConfigurationProvider map
|
|||
{
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<LicenseDto>> GetAllAsync() =>
|
||||
await DbContext.Licenses
|
||||
.ProjectTo<LicenseDto>(MapConfig)
|
||||
.ToListAsync();
|
||||
private IQueryable<Data.Entities.License> ImplementedLicenses =>
|
||||
DbContext.Licenses.Where(l => l.FilterLists.Any());
|
||||
|
||||
public async Task<LicenseDto> GetByIdAsync(int id) =>
|
||||
await DbContext.Licenses
|
||||
.ProjectTo<LicenseDto>(MapConfig)
|
||||
.FirstOrDefaultAsync(l => l.Id == id);
|
||||
public async Task<IEnumerable<LicenseDto>> GetAllImplementedAsync() =>
|
||||
await ImplementedLicenses.ProjectTo<LicenseDto>(MapConfig)
|
||||
.ToListAsync();
|
||||
|
||||
public async Task<LicenseDto> GetImplementedByIdAsync(int id) =>
|
||||
await ImplementedLicenses.ProjectTo<LicenseDto>(MapConfig)
|
||||
.FirstOrDefaultAsync(l => l.Id == id);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue