mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
rename FilterListService -> ListService
This commit is contained in:
parent
3f6ec50eb6
commit
16350fbea0
23 changed files with 60 additions and 62 deletions
|
|
@ -1,7 +1,7 @@
|
|||
using System.Threading.Tasks;
|
||||
using FilterLists.Api.V1.Interfaces;
|
||||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Services.FilterList;
|
||||
using FilterLists.Services.List;
|
||||
using FilterLists.Services.Seed;
|
||||
using FilterLists.Services.Seed.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
|
@ -11,19 +11,19 @@ namespace FilterLists.Api.V1.Controllers
|
|||
{
|
||||
public class ListsController : BaseController, IGet, ISeed
|
||||
{
|
||||
private readonly FilterListService filterListService;
|
||||
private readonly ListService listService;
|
||||
|
||||
public ListsController(IMemoryCache memoryCache, SeedService seedService, FilterListService filterListService) :
|
||||
base(memoryCache, seedService) => this.filterListService = filterListService;
|
||||
public ListsController(IMemoryCache memoryCache, SeedService seedService, ListService listService) :
|
||||
base(memoryCache, seedService) => this.listService = listService;
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll() =>
|
||||
await Get(() => filterListService.GetAllAsync());
|
||||
await Get(() => listService.GetAllAsync());
|
||||
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<IActionResult> GetById(int id) =>
|
||||
await Get(() => filterListService.GetDetailsAsync(id), id);
|
||||
await Get(() => listService.GetDetailsAsync(id), id);
|
||||
|
||||
[HttpGet("seed")]
|
||||
public async Task<IActionResult> Seed() =>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using FilterLists.Data;
|
||||
using FilterLists.Services.FilterList;
|
||||
using FilterLists.Services.Language;
|
||||
using FilterLists.Services.List;
|
||||
using FilterLists.Services.Seed;
|
||||
using FilterLists.Services.Snapshot;
|
||||
using FilterLists.Services.Software;
|
||||
|
|
@ -22,7 +23,7 @@ public static void AddFilterListsApiServices(this IServiceCollection services, I
|
|||
.AddDbContextPool<FilterListsDbContext>(o =>
|
||||
o.UseMySql(config.GetConnectionString("FilterListsConnection"),
|
||||
m => m.MigrationsAssembly("FilterLists.Api")));
|
||||
services.TryAddScoped<FilterListService>();
|
||||
services.TryAddScoped<ListService>();
|
||||
services.TryAddScoped<LanguageService>();
|
||||
services.TryAddScoped<SeedService>();
|
||||
services.TryAddScoped<SoftwareService>();
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Services.FilterList.Models;
|
||||
|
||||
namespace FilterLists.Services.FilterList
|
||||
{
|
||||
public static class FilterListServiceExtensions
|
||||
{
|
||||
public static async Task<ListDetails> FilterParentListFromMaintainerAdditionalLists(
|
||||
this Task<ListDetails> listDetailsDtos)
|
||||
{
|
||||
foreach (var maintainer in listDetailsDtos.Result.Maintainers)
|
||||
maintainer.AdditionalLists = maintainer
|
||||
.AdditionalLists.Where(additionalList =>
|
||||
additionalList.Id != listDetailsDtos.Result.Id)
|
||||
.ToList();
|
||||
return await listDetailsDtos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,22 +4,22 @@
|
|||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
using FilterLists.Data;
|
||||
using FilterLists.Services.FilterList.Models;
|
||||
using FilterLists.Services.List.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FilterLists.Services.FilterList
|
||||
namespace FilterLists.Services.List
|
||||
{
|
||||
public class FilterListService : Service
|
||||
public class ListService : Service
|
||||
{
|
||||
public FilterListService(FilterListsDbContext dbContext, IConfigurationProvider mapConfig)
|
||||
public ListService(FilterListsDbContext dbContext, IConfigurationProvider mapConfig)
|
||||
: base(dbContext, mapConfig)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<List>> GetAllAsync() =>
|
||||
public async Task<IEnumerable<Models.List>> GetAllAsync() =>
|
||||
await DbContext.FilterLists
|
||||
.OrderBy(l => l.Name)
|
||||
.ProjectTo<List>(MapConfig)
|
||||
.ProjectTo<Models.List>(MapConfig)
|
||||
.ToListAsync();
|
||||
|
||||
public async Task<ListDetails> GetDetailsAsync(int id) =>
|
||||
19
src/FilterLists.Services/List/ListServiceExtensions.cs
Normal file
19
src/FilterLists.Services/List/ListServiceExtensions.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Services.List.Models;
|
||||
|
||||
namespace FilterLists.Services.List
|
||||
{
|
||||
public static class ListServiceExtensions
|
||||
{
|
||||
public static async Task<ListDetails> FilterParentListFromMaintainerAdditionalLists(
|
||||
this Task<ListDetails> listDetailsDtos)
|
||||
{
|
||||
foreach (var maintainer in listDetailsDtos.Result.Maintainers)
|
||||
maintainer.AdditionalLists = maintainer.AdditionalLists
|
||||
.Where(a => a.Id != listDetailsDtos.Result.Id)
|
||||
.ToList();
|
||||
return await listDetailsDtos;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using FilterLists.Services.FilterList.Models;
|
||||
using FilterLists.Services.List.Models;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.FilterList.MappingProfiles
|
||||
namespace FilterLists.Services.List.MappingProfiles
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ListDetailsDtoMappingProfile : Profile
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Services.FilterList.Models;
|
||||
using FilterLists.Services.List.Models;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.FilterList.MappingProfiles
|
||||
namespace FilterLists.Services.List.MappingProfiles
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ListMaintainerDtoMappingProfile : Profile
|
||||
|
|
@ -1,16 +1,15 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using FilterLists.Services.FilterList.Models;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.FilterList.MappingProfiles
|
||||
namespace FilterLists.Services.List.MappingProfiles
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ListMappingProfile : Profile
|
||||
{
|
||||
public ListMappingProfile() =>
|
||||
CreateMap<Data.Entities.FilterList, List>()
|
||||
CreateMap<Data.Entities.FilterList, Models.List>()
|
||||
.ForMember(dest => dest.Id,
|
||||
opt => opt.MapFrom(src =>
|
||||
(int)src.Id))
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Services.FilterList.Models;
|
||||
using FilterLists.Services.List.Models;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.FilterList.MappingProfiles
|
||||
namespace FilterLists.Services.List.MappingProfiles
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ListSyntaxDtoMappingProfile : Profile
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using AutoMapper;
|
||||
using FilterLists.Services.FilterList.Models;
|
||||
using FilterLists.Services.List.Models;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.FilterList.MappingProfiles
|
||||
namespace FilterLists.Services.List.MappingProfiles
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ListTagDtoMappingProfile : Profile
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
using AutoMapper;
|
||||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Services.FilterList.Models;
|
||||
using FilterLists.Services.List.Models;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.FilterList.MappingProfiles
|
||||
namespace FilterLists.Services.List.MappingProfiles
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class MaintainerAdditionalListsDtoMappingProfile : Profile
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using AutoMapper;
|
||||
using FilterLists.Services.FilterList.Models;
|
||||
using FilterLists.Services.List.Models;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.FilterList.MappingProfiles
|
||||
namespace FilterLists.Services.List.MappingProfiles
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class SyntaxSupportedSoftwareDtoMappingProfile : Profile
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.FilterList.Models
|
||||
namespace FilterLists.Services.List.Models
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class List
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.FilterList.Models
|
||||
namespace FilterLists.Services.List.Models
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ListDetails
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.FilterList.Models
|
||||
namespace FilterLists.Services.List.Models
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ListLanguagesDto
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.FilterList.Models
|
||||
namespace FilterLists.Services.List.Models
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ListLicenseDto
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.FilterList.Models
|
||||
namespace FilterLists.Services.List.Models
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ListMaintainerDto
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.FilterList.Models
|
||||
namespace FilterLists.Services.List.Models
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ListSyntaxDto
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.FilterList.Models
|
||||
namespace FilterLists.Services.List.Models
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ListTagDto
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.FilterList.Models
|
||||
namespace FilterLists.Services.List.Models
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class MaintainerAdditionalListsDto
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using JetBrains.Annotations;
|
||||
|
||||
namespace FilterLists.Services.FilterList.Models
|
||||
namespace FilterLists.Services.List.Models
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class SyntaxSupportedSoftwareDto
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace FilterLists.Services.FilterList
|
||||
namespace FilterLists.Services.List
|
||||
{
|
||||
public static class TagColors
|
||||
{
|
||||
|
|
@ -5,14 +5,14 @@
|
|||
namespace FilterLists.Services
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class Service
|
||||
public abstract class Service
|
||||
{
|
||||
protected readonly FilterListsDbContext DbContext;
|
||||
protected readonly IConfigurationProvider MapConfig;
|
||||
|
||||
public Service(FilterListsDbContext dbContext) => DbContext = dbContext;
|
||||
protected Service(FilterListsDbContext dbContext) => DbContext = dbContext;
|
||||
|
||||
public Service(FilterListsDbContext dbContext, IConfigurationProvider mapConfig)
|
||||
protected Service(FilterListsDbContext dbContext, IConfigurationProvider mapConfig)
|
||||
{
|
||||
DbContext = dbContext;
|
||||
MapConfig = mapConfig;
|
||||
|
|
|
|||
Loading…
Reference in a new issue