feat(api): exclude soft-deleted FilterLists from API

This commit is contained in:
Collin M. Barrett 2020-07-05 13:42:40 -05:00
parent 599a9aa0d2
commit 20d4492f2f

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using AutoMapper.QueryableExtensions;
@ -15,14 +16,20 @@ public FilterListService(FilterListsDbContext dbContext, IConfigurationProvider
{
}
public async Task<IEnumerable<FilterListDto>> GetAllAsync() =>
await DbContext.FilterLists
.ProjectTo<FilterListDto>(MapConfig)
.ToListAsync();
public async Task<IEnumerable<FilterListDto>> GetAllAsync()
{
return await DbContext.FilterLists
.Where(fl => fl.IsDeleted != true)
.ProjectTo<FilterListDto>(MapConfig)
.ToListAsync();
}
public async Task<FilterListDto> GetByIdAsync(int id) =>
await DbContext.FilterLists
.ProjectTo<FilterListDto>(MapConfig)
.FirstOrDefaultAsync(l => l.Id == id);
public async Task<FilterListDto> GetByIdAsync(int id)
{
return await DbContext.FilterLists
.Where(fl => fl.IsDeleted != true)
.ProjectTo<FilterListDto>(MapConfig)
.FirstOrDefaultAsync(l => l.Id == id);
}
}
}