mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
api plumbing tweaks
This commit is contained in:
parent
323f35a1e1
commit
77e98824d2
7 changed files with 12 additions and 11 deletions
|
|
@ -20,7 +20,7 @@ public async Task<IActionResult> Index() =>
|
|||
Json(await MemoryCache.GetOrCreate("ListsController_Index", entry =>
|
||||
{
|
||||
entry.AbsoluteExpirationRelativeToNow = MemoryCacheExpirationDefault;
|
||||
return filterListService.GetIndexAsync();
|
||||
return filterListService.GetAllAsync();
|
||||
}));
|
||||
|
||||
[HttpGet]
|
||||
|
|
|
|||
|
|
@ -16,14 +16,15 @@ public FilterListService(FilterListsDbContext dbContext, IConfigurationProvider
|
|||
{
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ListIndexRecord>> GetIndexAsync() =>
|
||||
public async Task<IEnumerable<List>> GetAllAsync() =>
|
||||
await DbContext.FilterLists
|
||||
.OrderBy(l => l.Name)
|
||||
.ProjectTo<ListIndexRecord>(MapConfig)
|
||||
.ProjectTo<List>(MapConfig)
|
||||
.ToListAsync();
|
||||
|
||||
public async Task<ListDetailsDto> GetDetailsAsync(uint id) =>
|
||||
await DbContext.FilterLists.ProjectTo<ListDetailsDto>(MapConfig)
|
||||
public async Task<ListDetails> GetDetailsAsync(uint id) =>
|
||||
await DbContext.FilterLists
|
||||
.ProjectTo<ListDetails>(MapConfig)
|
||||
.FirstOrDefaultAsync(x => x.Id == id)
|
||||
.FilterParentListFromMaintainerAdditionalLists();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ namespace FilterLists.Services.FilterList
|
|||
{
|
||||
public static class FilterListServiceExtensions
|
||||
{
|
||||
public static async Task<ListDetailsDto> FilterParentListFromMaintainerAdditionalLists(
|
||||
this Task<ListDetailsDto> listDetailsDtos)
|
||||
public static async Task<ListDetails> FilterParentListFromMaintainerAdditionalLists(
|
||||
this Task<ListDetails> listDetailsDtos)
|
||||
{
|
||||
foreach (var maintainer in listDetailsDtos.Result.Maintainers)
|
||||
maintainer.AdditionalLists = maintainer
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace FilterLists.Services.FilterList.MappingProfiles
|
|||
public class ListDetailsDtoMappingProfile : Profile
|
||||
{
|
||||
public ListDetailsDtoMappingProfile() =>
|
||||
CreateMap<Data.Entities.FilterList, ListDetailsDto>()
|
||||
CreateMap<Data.Entities.FilterList, ListDetails>()
|
||||
.ForMember(dest => dest.Id,
|
||||
opt => opt.MapFrom(src =>
|
||||
(int)src.Id))
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace FilterLists.Services.FilterList.MappingProfiles
|
|||
public class ListIndexRecordMappingProfile : Profile
|
||||
{
|
||||
public ListIndexRecordMappingProfile() =>
|
||||
CreateMap<Data.Entities.FilterList, ListIndexRecord>()
|
||||
CreateMap<Data.Entities.FilterList, List>()
|
||||
.ForMember(dest => dest.Id,
|
||||
opt => opt.MapFrom(src =>
|
||||
(int)src.Id))
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
namespace FilterLists.Services.FilterList.Models
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ListIndexRecord
|
||||
public class List
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public List<int> LanguageIds { get; set; }
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
namespace FilterLists.Services.FilterList.Models
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ListDetailsDto
|
||||
public class ListDetails
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ChatUrl { get; set; }
|
||||
Loading…
Reference in a new issue