diff --git a/src/FilterLists.Api/Controllers/ListsController.cs b/src/FilterLists.Api/Controllers/ListsController.cs index 6481a32cf..ac973fa36 100644 --- a/src/FilterLists.Api/Controllers/ListsController.cs +++ b/src/FilterLists.Api/Controllers/ListsController.cs @@ -9,11 +9,11 @@ namespace FilterLists.Api.Controllers [Produces("application/json")] public class ListsController : Controller { - private readonly IListService listService; + private readonly IFilterListService filterListService; - public ListsController(IListService listService) + public ListsController(IFilterListService filterListService) { - this.listService = listService; + this.filterListService = filterListService; } /// @@ -23,7 +23,7 @@ public ListsController(IListService listService) [HttpGet] public IActionResult Get() { - return Json(listService.GetAll()); + return Json(filterListService.GetAll()); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/Contexts/FilterListsDbContext.cs b/src/FilterLists.Data/Contexts/FilterListsDbContext.cs index 2a3e62dd5..6cde66706 100644 --- a/src/FilterLists.Data/Contexts/FilterListsDbContext.cs +++ b/src/FilterLists.Data/Contexts/FilterListsDbContext.cs @@ -10,7 +10,6 @@ public FilterListsDbContext(DbContextOptions options) { } - public DbSet List { get; set; } - public DbSet TableCsv { get; set; } + public DbSet FilterList { get; set; } } } \ No newline at end of file diff --git a/src/FilterLists.Data/Contexts/IFilterListsDbContext.cs b/src/FilterLists.Data/Contexts/IFilterListsDbContext.cs index e90b00624..ae65825af 100644 --- a/src/FilterLists.Data/Contexts/IFilterListsDbContext.cs +++ b/src/FilterLists.Data/Contexts/IFilterListsDbContext.cs @@ -5,7 +5,6 @@ namespace FilterLists.Data.Contexts { public interface IFilterListsDbContext { - DbSet List { get; set; } - DbSet TableCsv { get; set; } + DbSet FilterList { get; set; } } } \ No newline at end of file diff --git a/src/FilterLists.Data/Json/JsonSampleGenerator.cs b/src/FilterLists.Data/Json/JsonSampleGenerator.cs index 839e3ac00..69bbd6653 100644 --- a/src/FilterLists.Data/Json/JsonSampleGenerator.cs +++ b/src/FilterLists.Data/Json/JsonSampleGenerator.cs @@ -18,7 +18,7 @@ public static void WriteSampleToFile() private static JObject GetSampleList() { - return (JObject) JToken.FromObject(new List + return (JObject) JToken.FromObject(new FilterList { Author = "John Doe", Description = "A sample list to filter out advertisements.", @@ -28,7 +28,7 @@ private static JObject GetSampleList() ForumUrl = "https://mysample.list/forum/", HomeUrl = "https://mysample.list/", IssuesUrl = "https://github.com/mysamplelist/issues", - Name = "My Sample List", + Name = "My Sample Filter List", ViewUrl = "https://mysample.list/list.txt" }); } diff --git a/src/FilterLists.Data/Json/JsonSchemaGenerator.cs b/src/FilterLists.Data/Json/JsonSchemaGenerator.cs index 309b0dc7c..5a75e72ed 100644 --- a/src/FilterLists.Data/Json/JsonSchemaGenerator.cs +++ b/src/FilterLists.Data/Json/JsonSchemaGenerator.cs @@ -13,7 +13,7 @@ public static void WriteSchemaToFile() { File.WriteAllText( Path.GetFullPath(Path.Combine(AppContext.BaseDirectory + @"\", @"..\..\..\..\..\data\")) + - "ListSchema.json", new JSchemaGenerator().Generate(typeof(List)).ToString()); + "ListSchema.json", new JSchemaGenerator().Generate(typeof(FilterList)).ToString()); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/Migrations/20170410220415_Initial.Designer.cs b/src/FilterLists.Data/Migrations/20170410220415_Initial.Designer.cs deleted file mode 100644 index 53e893075..000000000 --- a/src/FilterLists.Data/Migrations/20170410220415_Initial.Designer.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using FilterLists.Data.Contexts; - -namespace FilterLists.Data.Migrations -{ - [DbContext(typeof(FilterListsDbContext))] - [Migration("20170410220415_Initial")] - partial class Initial - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { - modelBuilder - .HasAnnotation("ProductVersion", "1.1.1"); - - modelBuilder.Entity("FilterLists.Models.List", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("AddedDateUtc") - .ValueGeneratedOnAdd(); - - b.Property("Description") - .HasMaxLength(512); - - b.Property("DescriptionSourceUrl") - .HasMaxLength(2083); - - b.Property("DonateUrl") - .HasMaxLength(2083); - - b.Property("Email") - .HasMaxLength(254); - - b.Property("ForumUrl") - .HasMaxLength(2083); - - b.Property("HomeUrl") - .HasMaxLength(2083); - - b.Property("IssuesUrl") - .HasMaxLength(2083); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate(); - - b.Property("Name") - .HasMaxLength(64); - - b.Property("ViewUrl") - .IsRequired() - .HasMaxLength(2083); - - b.HasKey("Id"); - - b.ToTable("List"); - }); - } - } -} diff --git a/src/FilterLists.Data/Migrations/20170410220415_Initial.cs b/src/FilterLists.Data/Migrations/20170410220415_Initial.cs deleted file mode 100644 index 77a13a8e8..000000000 --- a/src/FilterLists.Data/Migrations/20170410220415_Initial.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace FilterLists.Data.Migrations -{ - public partial class Initial : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - "List", - table => new - { - Id = table.Column(nullable: false) - .Annotation("MySQL:AutoIncrement", true), - AddedDateUtc = table.Column(nullable: false), - Description = table.Column(maxLength: 512, nullable: true), - DescriptionSourceUrl = table.Column(maxLength: 2083, nullable: true), - DonateUrl = table.Column(maxLength: 2083, nullable: true), - Email = table.Column(maxLength: 254, nullable: true), - ForumUrl = table.Column(maxLength: 2083, nullable: true), - HomeUrl = table.Column(maxLength: 2083, nullable: true), - IssuesUrl = table.Column(maxLength: 2083, nullable: true), - ModifiedDateUtc = table.Column(nullable: false), - Name = table.Column(maxLength: 64, nullable: true), - ViewUrl = table.Column(maxLength: 2083, nullable: false) - }, - constraints: table => { table.PrimaryKey("PK_List", x => x.Id); }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - "List"); - } - } -} \ No newline at end of file diff --git a/src/FilterLists.Data/Migrations/20170625164836_AddAuthor.Designer.cs b/src/FilterLists.Data/Migrations/20170625164836_AddAuthor.Designer.cs deleted file mode 100644 index 068faac5b..000000000 --- a/src/FilterLists.Data/Migrations/20170625164836_AddAuthor.Designer.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using FilterLists.Data.Contexts; - -namespace FilterLists.Data.Migrations -{ - [DbContext(typeof(FilterListsDbContext))] - [Migration("20170625164836_AddAuthor")] - partial class AddAuthor - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { - modelBuilder - .HasAnnotation("ProductVersion", "1.1.2"); - - modelBuilder.Entity("FilterLists.Data.Models.List", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("AddedDateUtc") - .ValueGeneratedOnAdd(); - - b.Property("Author") - .HasMaxLength(126); - - b.Property("Description") - .HasMaxLength(1022); - - b.Property("DescriptionSourceUrl") - .HasMaxLength(2083); - - b.Property("DonateUrl") - .HasMaxLength(2083); - - b.Property("Email") - .HasMaxLength(126); - - b.Property("ForumUrl") - .HasMaxLength(2083); - - b.Property("HomeUrl") - .HasMaxLength(2083); - - b.Property("IssuesUrl") - .HasMaxLength(2083); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate(); - - b.Property("Name") - .HasMaxLength(126); - - b.Property("ViewUrl") - .IsRequired() - .HasMaxLength(2083); - - b.HasKey("Id"); - - b.ToTable("List"); - }); - } - } -} diff --git a/src/FilterLists.Data/Migrations/20170625164836_AddAuthor.cs b/src/FilterLists.Data/Migrations/20170625164836_AddAuthor.cs deleted file mode 100644 index bdb07dc7d..000000000 --- a/src/FilterLists.Data/Migrations/20170625164836_AddAuthor.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace FilterLists.Data.Migrations -{ - public partial class AddAuthor : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - "Name", - "List", - maxLength: 126, - nullable: true, - oldClrType: typeof(string), - oldMaxLength: 64, - oldNullable: true); - - migrationBuilder.AlterColumn( - "ModifiedDateUtc", - "List", - nullable: true, - oldClrType: typeof(DateTime)); - - migrationBuilder.AlterColumn( - "Email", - "List", - maxLength: 126, - nullable: true, - oldClrType: typeof(string), - oldMaxLength: 254, - oldNullable: true); - - migrationBuilder.AlterColumn( - "Description", - "List", - maxLength: 1022, - nullable: true, - oldClrType: typeof(string), - oldMaxLength: 512, - oldNullable: true); - - migrationBuilder.AddColumn( - "Author", - "List", - maxLength: 126, - nullable: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - "Author", - "List"); - - migrationBuilder.AlterColumn( - "Name", - "List", - maxLength: 64, - nullable: true, - oldClrType: typeof(string), - oldMaxLength: 126, - oldNullable: true); - - migrationBuilder.AlterColumn( - "ModifiedDateUtc", - "List", - nullable: false, - oldClrType: typeof(DateTime), - oldNullable: true); - - migrationBuilder.AlterColumn( - "Email", - "List", - maxLength: 254, - nullable: true, - oldClrType: typeof(string), - oldMaxLength: 126, - oldNullable: true); - - migrationBuilder.AlterColumn( - "Description", - "List", - maxLength: 512, - nullable: true, - oldClrType: typeof(string), - oldMaxLength: 1022, - oldNullable: true); - } - } -} \ No newline at end of file diff --git a/src/FilterLists.Data/Migrations/20170625223511_addTableCsvEntity.Designer.cs b/src/FilterLists.Data/Migrations/20170625223511_addTableCsvEntity.Designer.cs deleted file mode 100644 index 804ee29cb..000000000 --- a/src/FilterLists.Data/Migrations/20170625223511_addTableCsvEntity.Designer.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using FilterLists.Data.Contexts; - -namespace FilterLists.Data.Migrations -{ - [DbContext(typeof(FilterListsDbContext))] - [Migration("20170625223511_addTableCsvEntity")] - partial class addTableCsvEntity - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { - modelBuilder - .HasAnnotation("ProductVersion", "1.1.2"); - - modelBuilder.Entity("FilterLists.Data.Models.List", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("AddedDateUtc") - .ValueGeneratedOnAdd(); - - b.Property("Author") - .HasMaxLength(126); - - b.Property("Description") - .HasMaxLength(1022); - - b.Property("DescriptionSourceUrl") - .HasMaxLength(2083); - - b.Property("DonateUrl") - .HasMaxLength(2083); - - b.Property("Email") - .HasMaxLength(126); - - b.Property("ForumUrl") - .HasMaxLength(2083); - - b.Property("HomeUrl") - .HasMaxLength(2083); - - b.Property("IssuesUrl") - .HasMaxLength(2083); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate(); - - b.Property("Name") - .HasMaxLength(126); - - b.Property("ViewUrl") - .IsRequired() - .HasMaxLength(2083); - - b.HasKey("Id"); - - b.ToTable("List"); - }); - - modelBuilder.Entity("FilterLists.Data.Models.TableCsv", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("AddedDateUtc") - .ValueGeneratedOnAdd(); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate(); - - b.Property("Name") - .IsRequired() - .HasMaxLength(126); - - b.Property("Url") - .IsRequired() - .HasMaxLength(2083); - - b.HasKey("Id"); - - b.ToTable("TableCsv"); - }); - } - } -} diff --git a/src/FilterLists.Data/Migrations/20170625223511_addTableCsvEntity.cs b/src/FilterLists.Data/Migrations/20170625223511_addTableCsvEntity.cs deleted file mode 100644 index f1d316260..000000000 --- a/src/FilterLists.Data/Migrations/20170625223511_addTableCsvEntity.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace FilterLists.Data.Migrations -{ - public partial class addTableCsvEntity : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - "TableCsv", - table => new - { - Id = table.Column(nullable: false) - .Annotation("MySQL:AutoIncrement", true), - AddedDateUtc = table.Column(nullable: false), - ModifiedDateUtc = table.Column(nullable: true), - Name = table.Column(maxLength: 126, nullable: false), - Url = table.Column(maxLength: 2083, nullable: false) - }, - constraints: table => { table.PrimaryKey("PK_TableCsv", x => x.Id); }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - "TableCsv"); - } - } -} \ No newline at end of file diff --git a/src/FilterLists.Data/Migrations/FilterListsDbContextModelSnapshot.cs b/src/FilterLists.Data/Migrations/FilterListsDbContextModelSnapshot.cs deleted file mode 100644 index 7f22f7d8c..000000000 --- a/src/FilterLists.Data/Migrations/FilterListsDbContextModelSnapshot.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using FilterLists.Data.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; - -namespace FilterLists.Data.Migrations -{ - [DbContext(typeof(FilterListsDbContext))] - internal class FilterListsDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { - modelBuilder - .HasAnnotation("ProductVersion", "1.1.2"); - - modelBuilder.Entity("FilterLists.Data.Models.List", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("AddedDateUtc") - .ValueGeneratedOnAdd(); - - b.Property("Author") - .HasMaxLength(126); - - b.Property("Description") - .HasMaxLength(1022); - - b.Property("DescriptionSourceUrl") - .HasMaxLength(2083); - - b.Property("DonateUrl") - .HasMaxLength(2083); - - b.Property("Email") - .HasMaxLength(126); - - b.Property("ForumUrl") - .HasMaxLength(2083); - - b.Property("HomeUrl") - .HasMaxLength(2083); - - b.Property("IssuesUrl") - .HasMaxLength(2083); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate(); - - b.Property("Name") - .HasMaxLength(126); - - b.Property("ViewUrl") - .IsRequired() - .HasMaxLength(2083); - - b.HasKey("Id"); - - b.ToTable("List"); - }); - - modelBuilder.Entity("FilterLists.Data.Models.TableCsv", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("AddedDateUtc") - .ValueGeneratedOnAdd(); - - b.Property("ModifiedDateUtc") - .ValueGeneratedOnAddOrUpdate(); - - b.Property("Name") - .IsRequired() - .HasMaxLength(126); - - b.Property("Url") - .IsRequired() - .HasMaxLength(2083); - - b.HasKey("Id"); - - b.ToTable("TableCsv"); - }); - } - } -} \ No newline at end of file diff --git a/src/FilterLists.Data/Models/Contracts/IList.cs b/src/FilterLists.Data/Models/Contracts/IFilterList.cs similarity index 94% rename from src/FilterLists.Data/Models/Contracts/IList.cs rename to src/FilterLists.Data/Models/Contracts/IFilterList.cs index b98686343..13bca2f8d 100644 --- a/src/FilterLists.Data/Models/Contracts/IList.cs +++ b/src/FilterLists.Data/Models/Contracts/IFilterList.cs @@ -2,7 +2,7 @@ namespace FilterLists.Data.Models.Contracts { - public interface IList + public interface IFilterList { string Author { get; set; } string Description { get; set; } diff --git a/src/FilterLists.Data/Models/Contracts/ITableCsv.cs b/src/FilterLists.Data/Models/Contracts/ITableCsv.cs deleted file mode 100644 index 5583fe2ad..000000000 --- a/src/FilterLists.Data/Models/Contracts/ITableCsv.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; - -namespace FilterLists.Data.Models.Contracts -{ - public interface ITableCsv - { - string Name { get; set; } - string Url { get; set; } - long Id { get; set; } - DateTime AddedDateUtc { get; set; } - DateTime? ModifiedDateUtc { get; set; } - } -} \ No newline at end of file diff --git a/src/FilterLists.Data/Models/Implementations/List.cs b/src/FilterLists.Data/Models/Implementations/FilterList.cs similarity index 98% rename from src/FilterLists.Data/Models/Implementations/List.cs rename to src/FilterLists.Data/Models/Implementations/FilterList.cs index 22b0e7e6a..7a792fa72 100644 --- a/src/FilterLists.Data/Models/Implementations/List.cs +++ b/src/FilterLists.Data/Models/Implementations/FilterList.cs @@ -4,7 +4,7 @@ namespace FilterLists.Data.Models.Implementations { - public class List : BaseEntity, IList + public class FilterList : BaseEntity, IFilterList { [Description(@"The author (person or group) who maintains the list.")] [MaxLength(126)] diff --git a/src/FilterLists.Data/Models/Implementations/TableCsv.cs b/src/FilterLists.Data/Models/Implementations/TableCsv.cs deleted file mode 100644 index f408cb1cf..000000000 --- a/src/FilterLists.Data/Models/Implementations/TableCsv.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using FilterLists.Data.Models.Contracts; - -namespace FilterLists.Data.Models.Implementations -{ - public class TableCsv : BaseEntity, ITableCsv - { - [Required] - [MaxLength(126)] - public string Name { get; set; } - - [Required] - [MaxLength(2083)] - [MinLength(6)] - public string Url { get; set; } - } -} \ No newline at end of file diff --git a/src/FilterLists.Data/Repositories/Contracts/IListRepository.cs b/src/FilterLists.Data/Repositories/Contracts/IFilterListRepository.cs similarity index 50% rename from src/FilterLists.Data/Repositories/Contracts/IListRepository.cs rename to src/FilterLists.Data/Repositories/Contracts/IFilterListRepository.cs index 645864863..4aef879cc 100644 --- a/src/FilterLists.Data/Repositories/Contracts/IListRepository.cs +++ b/src/FilterLists.Data/Repositories/Contracts/IFilterListRepository.cs @@ -3,9 +3,9 @@ namespace FilterLists.Data.Repositories.Contracts { - public interface IListRepository + public interface IFilterListRepository { - IEnumerable GetAll(); - IList GetByName(string listName); + IEnumerable GetAll(); + IFilterList GetByName(string filterListName); } } \ No newline at end of file diff --git a/src/FilterLists.Data/Repositories/Contracts/ITableCsvRepository.cs b/src/FilterLists.Data/Repositories/Contracts/ITableCsvRepository.cs deleted file mode 100644 index b7fbab848..000000000 --- a/src/FilterLists.Data/Repositories/Contracts/ITableCsvRepository.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; -using FilterLists.Data.Models.Contracts; - -namespace FilterLists.Data.Repositories.Contracts -{ - public interface ITableCsvRepository - { - IEnumerable GetAll(); - string GetUrlByName(string name); - } -} \ No newline at end of file diff --git a/src/FilterLists.Data/Repositories/Implementations/TableCsvRepository.cs b/src/FilterLists.Data/Repositories/Implementations/FilterListRepository.cs similarity index 52% rename from src/FilterLists.Data/Repositories/Implementations/TableCsvRepository.cs rename to src/FilterLists.Data/Repositories/Implementations/FilterListRepository.cs index daf17858b..eb9e3f40d 100644 --- a/src/FilterLists.Data/Repositories/Implementations/TableCsvRepository.cs +++ b/src/FilterLists.Data/Repositories/Implementations/FilterListRepository.cs @@ -6,23 +6,23 @@ namespace FilterLists.Data.Repositories.Implementations { - public class TableCsvRepository : ITableCsvRepository + public class FilterListRepository : IFilterListRepository { private readonly IFilterListsDbContext filterListsDbContext; - public TableCsvRepository(FilterListsDbContext filterListsDbContext) + public FilterListRepository(FilterListsDbContext filterListsDbContext) { this.filterListsDbContext = filterListsDbContext; } - public IEnumerable GetAll() + public IEnumerable GetAll() { - return filterListsDbContext.TableCsv.AsEnumerable(); + return filterListsDbContext.FilterList.AsEnumerable(); } - public string GetUrlByName(string name) + public IFilterList GetByName(string filterListName) { - return filterListsDbContext.TableCsv.FirstOrDefault(x => x.Name == name).Url; + return filterListsDbContext.FilterList.First(x => x.Name == filterListName); } } } \ No newline at end of file diff --git a/src/FilterLists.Data/Repositories/Implementations/ListRepository.cs b/src/FilterLists.Data/Repositories/Implementations/ListRepository.cs deleted file mode 100644 index e2a29dddc..000000000 --- a/src/FilterLists.Data/Repositories/Implementations/ListRepository.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using FilterLists.Data.Contexts; -using FilterLists.Data.Models.Contracts; -using FilterLists.Data.Repositories.Contracts; - -namespace FilterLists.Data.Repositories.Implementations -{ - public class ListRepository : IListRepository - { - private readonly IFilterListsDbContext filterListsDbContext; - - public ListRepository(FilterListsDbContext filterListsDbContext) - { - this.filterListsDbContext = filterListsDbContext; - } - - public IEnumerable GetAll() - { - return filterListsDbContext.List.AsEnumerable(); - } - - public IList GetByName(string listName) - { - return filterListsDbContext.List.First(x => x.Name == listName); - } - } -} \ No newline at end of file diff --git a/src/FilterLists.Services/Contracts/IListService.cs b/src/FilterLists.Services/Contracts/IFilterListService.cs similarity index 61% rename from src/FilterLists.Services/Contracts/IListService.cs rename to src/FilterLists.Services/Contracts/IFilterListService.cs index df4a57c6b..457874c46 100644 --- a/src/FilterLists.Services/Contracts/IListService.cs +++ b/src/FilterLists.Services/Contracts/IFilterListService.cs @@ -3,8 +3,8 @@ namespace FilterLists.Services.Contracts { - public interface IListService + public interface IFilterListService { - IEnumerable GetAll(); + IEnumerable GetAll(); } } \ No newline at end of file diff --git a/src/FilterLists.Services/Contracts/ITableService.cs b/src/FilterLists.Services/Contracts/ITableService.cs deleted file mode 100644 index 45e3f9702..000000000 --- a/src/FilterLists.Services/Contracts/ITableService.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace FilterLists.Services.Contracts -{ - public interface ITableService - { - void UpdateTables(); - } -} \ No newline at end of file diff --git a/src/FilterLists.Services/DependencyInjection/Extensions/ConfigureServicesCollection.cs b/src/FilterLists.Services/DependencyInjection/Extensions/ConfigureServicesCollection.cs index 5b8755968..eab1d8e71 100644 --- a/src/FilterLists.Services/DependencyInjection/Extensions/ConfigureServicesCollection.cs +++ b/src/FilterLists.Services/DependencyInjection/Extensions/ConfigureServicesCollection.cs @@ -17,10 +17,8 @@ public static void AddFilterListsServices(this IServiceCollection services, ICon services.AddSingleton(c => configuration); services.AddEntityFrameworkMySql().AddDbContext(options => options.UseMySql(configuration.GetConnectionString("FilterListsConnection"))); - services.TryAddScoped(); - services.TryAddScoped(); - services.TryAddScoped(); - services.TryAddScoped(); + services.TryAddScoped(); + services.TryAddScoped(); } } } \ No newline at end of file diff --git a/src/FilterLists.Services/FilterLists.Services.csproj b/src/FilterLists.Services/FilterLists.Services.csproj index 8dc0a1d39..28e2cb637 100644 --- a/src/FilterLists.Services/FilterLists.Services.csproj +++ b/src/FilterLists.Services/FilterLists.Services.csproj @@ -6,7 +6,6 @@ - diff --git a/src/FilterLists.Services/Implementations/FilterListService.cs b/src/FilterLists.Services/Implementations/FilterListService.cs new file mode 100644 index 000000000..c2553189c --- /dev/null +++ b/src/FilterLists.Services/Implementations/FilterListService.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using FilterLists.Data.Models.Contracts; +using FilterLists.Data.Repositories.Contracts; +using FilterLists.Services.Contracts; + +namespace FilterLists.Services.Implementations +{ + public class FilterListService : IFilterListService + { + private readonly IFilterListRepository filterListRepository; + + public FilterListService(IFilterListRepository filterListRepository) + { + this.filterListRepository = filterListRepository; + } + + public IEnumerable GetAll() + { + return filterListRepository.GetAll(); + } + } +} \ No newline at end of file diff --git a/src/FilterLists.Services/Implementations/ListService.cs b/src/FilterLists.Services/Implementations/ListService.cs deleted file mode 100644 index 2b1086d67..000000000 --- a/src/FilterLists.Services/Implementations/ListService.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Collections.Generic; -using FilterLists.Data.Models.Contracts; -using FilterLists.Data.Repositories.Contracts; -using FilterLists.Services.Contracts; - -namespace FilterLists.Services.Implementations -{ - public class ListService : IListService - { - private readonly IListRepository listRepository; - - public ListService(IListRepository listRepository) - { - this.listRepository = listRepository; - } - - public IEnumerable GetAll() - { - return listRepository.GetAll(); - } - } -} \ No newline at end of file diff --git a/src/FilterLists.Services/Implementations/TableService.cs b/src/FilterLists.Services/Implementations/TableService.cs deleted file mode 100644 index 31d5fc4d0..000000000 --- a/src/FilterLists.Services/Implementations/TableService.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.IO; -using System.Net.Http; -using System.Threading.Tasks; -using CsvHelper; -using FilterLists.Data.Models.Implementations; -using FilterLists.Data.Repositories.Contracts; -using FilterLists.Services.Contracts; - -namespace FilterLists.Services.Implementations -{ - public class TableService : ITableService - { - private readonly ITableCsvRepository tableCsvRepository; - - public TableService(ITableCsvRepository tableCsvRepository) - { - this.tableCsvRepository = tableCsvRepository; - } - - public void UpdateTables() - { - UpdateListTable(); - } - - public void UpdateListTable() - { - var localCsvFilePath = FetchFile(tableCsvRepository.GetUrlByName("List"), "List").Result; - TextReader textReader = File.OpenText(localCsvFilePath); - var csv = new CsvReader(textReader); - csv.Configuration.MissingFieldFound = null; - var records = csv.GetRecords(); - //TODO: delete file when finished - } - - private static async Task FetchFile(string url, string fileName) - { - var response = await new HttpClient().GetAsync(url); - response.EnsureSuccessStatusCode(); - var path = Path.Combine(Directory.GetCurrentDirectory(), "csv"); - Directory.CreateDirectory(path); - var file = Path.Combine(path, fileName + ".csv"); - using (var fileStream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None)) - { - await response.Content.CopyToAsync(fileStream); - } - return file; - } - } -} \ No newline at end of file