mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
general architecture cleanup
remove pointless (currently) interfaces and other cruft
This commit is contained in:
parent
a4ad616807
commit
4fa8093f4c
31 changed files with 89 additions and 100 deletions
|
|
@ -1,19 +1,20 @@
|
|||
using System;
|
||||
using FilterLists.Services.Contracts;
|
||||
using FilterLists.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace FilterLists.Api.V1.Controllers
|
||||
{
|
||||
[ApiVersion("1.0")]
|
||||
[Route("[controller]")]
|
||||
[Produces("application/json")]
|
||||
[ResponseCache(CacheProfileName = "Long-Lived")]
|
||||
public class ListsController : Controller
|
||||
{
|
||||
private readonly IFilterListService filterListService;
|
||||
private readonly FilterListService filterListService;
|
||||
private readonly IMemoryCache memoryCache;
|
||||
|
||||
public ListsController(IMemoryCache memoryCache, IFilterListService filterListService)
|
||||
public ListsController(IMemoryCache memoryCache, FilterListService filterListService)
|
||||
{
|
||||
this.memoryCache = memoryCache;
|
||||
this.filterListService = filterListService;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
|
||||
namespace FilterLists.Data.Entities
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
namespace FilterLists.Data.Entities
|
||||
namespace FilterLists.Data.Entities.Junctions
|
||||
{
|
||||
public class FilterListLanguage : BaseEntity
|
||||
{
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
namespace FilterLists.Data.Entities
|
||||
namespace FilterLists.Data.Entities.Junctions
|
||||
{
|
||||
public class FilterListMaintainer : BaseEntity
|
||||
{
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
namespace FilterLists.Data.Entities
|
||||
namespace FilterLists.Data.Entities.Junctions
|
||||
{
|
||||
public class FilterListRule : BaseEntity
|
||||
{
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
namespace FilterLists.Data.Entities
|
||||
namespace FilterLists.Data.Entities.Junctions
|
||||
{
|
||||
public class Fork : BaseEntity
|
||||
{
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
namespace FilterLists.Data.Entities
|
||||
namespace FilterLists.Data.Entities.Junctions
|
||||
{
|
||||
public class Merge : BaseEntity
|
||||
{
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
namespace FilterLists.Data.Entities
|
||||
namespace FilterLists.Data.Entities.Junctions
|
||||
{
|
||||
public class SoftwareSyntax : BaseEntity
|
||||
{
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
|
||||
namespace FilterLists.Data.Entities
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
|
||||
namespace FilterLists.Data.Entities
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
|
||||
namespace FilterLists.Data.Entities
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
|
||||
namespace FilterLists.Data.Entities
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
|
||||
namespace FilterLists.Data.Entities
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Data.EntityTypeConfigurations
|
||||
namespace FilterLists.Data.EntityTypeConfigurations.Junctions
|
||||
{
|
||||
public class FilterListLanguageTypeConfiguration : BaseEntityTypeConfiguration<FilterListLanguage>
|
||||
{
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Data.EntityTypeConfigurations
|
||||
namespace FilterLists.Data.EntityTypeConfigurations.Junctions
|
||||
{
|
||||
public class FilterListMaintainerTypeConfiguration : BaseEntityTypeConfiguration<FilterListMaintainer>
|
||||
{
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Data.EntityTypeConfigurations
|
||||
namespace FilterLists.Data.EntityTypeConfigurations.Junctions
|
||||
{
|
||||
public class FilterListRuleTypeConfiguration : BaseEntityTypeConfiguration<FilterListRule>
|
||||
{
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Data.EntityTypeConfigurations
|
||||
namespace FilterLists.Data.EntityTypeConfigurations.Junctions
|
||||
{
|
||||
public class ForkTypeConfiguration : BaseEntityTypeConfiguration<Fork>
|
||||
{
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Data.EntityTypeConfigurations
|
||||
namespace FilterLists.Data.EntityTypeConfigurations.Junctions
|
||||
{
|
||||
public class MergeTypeConfiguration : BaseEntityTypeConfiguration<Merge>
|
||||
{
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace FilterLists.Data.EntityTypeConfigurations
|
||||
namespace FilterLists.Data.EntityTypeConfigurations.Junctions
|
||||
{
|
||||
public class SoftwareSyntaxTypeConfiguration : BaseEntityTypeConfiguration<SoftwareSyntax>
|
||||
{
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
using FilterLists.Data.EntityTypeConfigurations;
|
||||
using FilterLists.Data.EntityTypeConfigurations.Junctions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FilterLists.Data
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using FilterLists.Data.Entities;
|
||||
|
||||
namespace FilterLists.Data.Repositories.Contracts
|
||||
{
|
||||
public interface IFilterListRepository
|
||||
{
|
||||
IEnumerable<FilterList> GetAll();
|
||||
FilterList Get(int id);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,10 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Data.Repositories.Contracts;
|
||||
|
||||
namespace FilterLists.Data.Repositories.Implementations
|
||||
namespace FilterLists.Data.Repositories
|
||||
{
|
||||
public class FilterListRepository : IFilterListRepository
|
||||
public class FilterListRepository
|
||||
{
|
||||
private readonly FilterListsDbContext filterListsDbContext;
|
||||
|
||||
|
|
@ -18,10 +17,5 @@ public IEnumerable<FilterList> GetAll()
|
|||
{
|
||||
return filterListsDbContext.FilterLists.AsEnumerable();
|
||||
}
|
||||
|
||||
public FilterList Get(int id)
|
||||
{
|
||||
return filterListsDbContext.FilterLists.Single(x => x.Id == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using FilterLists.Data.Entities;
|
||||
using FilterLists.Data.Entities.Junctions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Newtonsoft.Json;
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using FilterLists.Services.Models;
|
||||
|
||||
namespace FilterLists.Services.Contracts
|
||||
{
|
||||
public interface IFilterListService
|
||||
{
|
||||
IEnumerable<FilterListSummaryDto> GetAllSummaries();
|
||||
FilterListDetailsDto GetDetails(int id);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
using AutoMapper;
|
||||
using FilterLists.Data;
|
||||
using FilterLists.Data.Repositories.Contracts;
|
||||
using FilterLists.Data.Repositories.Implementations;
|
||||
using FilterLists.Services.Contracts;
|
||||
using FilterLists.Services.Implementations;
|
||||
using FilterLists.Data.Repositories;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
|
@ -19,8 +16,8 @@ public static void AddFilterListsServices(this IServiceCollection services, ICon
|
|||
services.AddEntityFrameworkMySql().AddDbContextPool<FilterListsDbContext>(options =>
|
||||
options.UseMySql(configuration.GetConnectionString("FilterListsConnection"),
|
||||
b => b.MigrationsAssembly("FilterLists.Api")));
|
||||
services.TryAddScoped<IFilterListRepository, FilterListRepository>();
|
||||
services.TryAddScoped<IFilterListService, FilterListService>();
|
||||
services.TryAddScoped<FilterListRepository>();
|
||||
services.TryAddScoped<FilterListService>();
|
||||
services.AddAutoMapper();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
29
src/FilterLists.Services/FilterListService.cs
Normal file
29
src/FilterLists.Services/FilterListService.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using System.Collections.Generic;
|
||||
using AutoMapper;
|
||||
using FilterLists.Data.Repositories;
|
||||
using FilterLists.Services.Models;
|
||||
|
||||
namespace FilterLists.Services
|
||||
{
|
||||
public class FilterListService
|
||||
{
|
||||
private readonly FilterListRepository filterListRepository;
|
||||
private readonly IMapper mapper;
|
||||
|
||||
public FilterListService(FilterListRepository filterListRepository, IMapper mapper)
|
||||
{
|
||||
this.filterListRepository = filterListRepository;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public IEnumerable<FilterListSummaryDto> GetAllSummaries()
|
||||
{
|
||||
return mapper.Map<IEnumerable<FilterListSummaryDto>>(filterListRepository.GetAll());
|
||||
}
|
||||
|
||||
public IEnumerable<FilterListSeedDto> GetAllSeeds()
|
||||
{
|
||||
return mapper.Map<IEnumerable<FilterListSeedDto>>(filterListRepository.GetAll());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using AutoMapper;
|
||||
using FilterLists.Data.Repositories.Contracts;
|
||||
using FilterLists.Services.Contracts;
|
||||
using FilterLists.Services.Models;
|
||||
|
||||
namespace FilterLists.Services.Implementations
|
||||
{
|
||||
public class FilterListService : IFilterListService
|
||||
{
|
||||
private readonly IFilterListRepository filterListRepository;
|
||||
private readonly IMapper mapper;
|
||||
|
||||
public FilterListService(IFilterListRepository filterListRepository, IMapper mapper)
|
||||
{
|
||||
this.filterListRepository = filterListRepository;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public IEnumerable<FilterListSummaryDto> GetAllSummaries()
|
||||
{
|
||||
return mapper.Map<IEnumerable<FilterListSummaryDto>>(filterListRepository.GetAll());
|
||||
}
|
||||
|
||||
public FilterListDetailsDto GetDetails(int id)
|
||||
{
|
||||
var list = filterListRepository.Get(id);
|
||||
var maintainer = list.FilterListMaintainers;
|
||||
//return mapper.Map<FilterListSummaryDto>(filterListRepository.GetBy)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ public class MappingProfile : MapperConfigurationExpression
|
|||
public MappingProfile()
|
||||
{
|
||||
CreateMap<FilterList, FilterListSummaryDto>();
|
||||
CreateMap<FilterList, FilterListSeedDto>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
namespace FilterLists.Services.Models
|
||||
{
|
||||
public class FilterListDetailsDto
|
||||
{
|
||||
public int Id;
|
||||
public string Description { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
22
src/FilterLists.Services/Models/FilterListSeedDto.cs
Normal file
22
src/FilterLists.Services/Models/FilterListSeedDto.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
|
||||
namespace FilterLists.Services.Models
|
||||
{
|
||||
public class FilterListSeedDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string DescriptionSourceUrl { get; set; }
|
||||
public DateTime? DiscontinuedDate { get; set; }
|
||||
public string DonateUrl { get; set; }
|
||||
public string EmailAddress { get; set; }
|
||||
public string ForumUrl { get; set; }
|
||||
public string HomeUrl { get; set; }
|
||||
public string IssuesUrl { get; set; }
|
||||
public int? LicenseId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string SubmissionUrl { get; set; }
|
||||
public int? SyntaxId { get; set; }
|
||||
public string ViewUrl { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
{
|
||||
public class FilterListSummaryDto
|
||||
{
|
||||
public int Id;
|
||||
public int Id { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue