mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
lots of changes to structure, etc.
This commit is contained in:
parent
4d93ecce21
commit
44894ceca1
18 changed files with 122 additions and 54 deletions
|
|
@ -19,6 +19,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FilterLists.Data\FilterLists.Data.csproj" />
|
||||
<ProjectReference Include="..\FilterLists.Services\FilterLists.Services.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using System.IO;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
||||
namespace FilterLists.API
|
||||
namespace FilterLists.Api
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
using FilterLists.Data;
|
||||
using FilterLists.Data.Contexts;
|
||||
using FilterLists.Services;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
|
@ -8,7 +10,7 @@
|
|||
using MySQL.Data.EntityFrameworkCore;
|
||||
using MySQL.Data.EntityFrameworkCore.Extensions;
|
||||
|
||||
namespace FilterLists.API
|
||||
namespace FilterLists.Api
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
|
|
@ -30,9 +32,10 @@ public void ConfigureServices(IServiceCollection services)
|
|||
// Add framework services.
|
||||
services.AddEntityFramework()
|
||||
.AddEntityFrameworkMySQL()
|
||||
.AddDbContext<FilterListsContext>(options =>
|
||||
.AddDbContext<FilterListsDbContext>(options =>
|
||||
options.UseMySQL(Configuration.GetConnectionString("FilterListsConnection")));
|
||||
services.AddMvc();
|
||||
services.AddTransient<IListService, ListService>();
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
|
|
|
|||
|
|
@ -1,38 +1,47 @@
|
|||
using System.Collections.Generic;
|
||||
using FilterLists.Services;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace FilterLists.API.Controllers
|
||||
namespace FilterLists.Api.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
public class ValuesController : Controller
|
||||
public class ListsController : Controller
|
||||
{
|
||||
// GET api/values
|
||||
private readonly IListService _listService;
|
||||
|
||||
public ListsController(IListService listService)
|
||||
{
|
||||
_listService = listService;
|
||||
}
|
||||
|
||||
// GET api/lists
|
||||
[HttpGet]
|
||||
public IEnumerable<string> Get()
|
||||
{
|
||||
return new[] {"value1", "value2"};
|
||||
var lists = _listService.Lists;
|
||||
return (IEnumerable<string>) lists;
|
||||
}
|
||||
|
||||
// GET api/values/5
|
||||
// GET api/lists/5
|
||||
[HttpGet("{id}")]
|
||||
public string Get(int id)
|
||||
{
|
||||
return "value";
|
||||
return "list";
|
||||
}
|
||||
|
||||
// POST api/values
|
||||
// POST api/lists
|
||||
[HttpPost]
|
||||
public void Post([FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// PUT api/values/5
|
||||
// PUT api/lists/5
|
||||
[HttpPut("{id}")]
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// DELETE api/values/5
|
||||
// DELETE api/lists/5
|
||||
[HttpDelete("{id}")]
|
||||
public void Delete(int id)
|
||||
{
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
namespace FilterLists.Data.Contracts.Contexts
|
||||
{
|
||||
public interface IFilterListsDbContext
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
namespace FilterLists.Data.Contracts
|
||||
{
|
||||
public interface IListRepository
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
namespace FilterLists.Data.Contracts.Repositories
|
||||
{
|
||||
public interface IListRepository
|
||||
{
|
||||
}
|
||||
}
|
||||
20
api/FilterLists.Data/Contexts/FilterListsDbContext.cs
Normal file
20
api/FilterLists.Data/Contexts/FilterListsDbContext.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
using FilterLists.Data.Contracts.Contexts;
|
||||
using FilterLists.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FilterLists.Data.Contexts
|
||||
{
|
||||
public class FilterListsDbContext : DbContext, IFilterListsDbContext
|
||||
{
|
||||
public FilterListsDbContext(DbContextOptions options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public FilterListsDbContext()
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<List> Lists { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
using FilterLists.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FilterLists.Data
|
||||
{
|
||||
public class FilterListsContext : DbContext
|
||||
{
|
||||
public FilterListsContext(DbContextOptions options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public FilterListsContext()
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<List> Lists { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
using FilterLists.Data.Contracts;
|
||||
using FilterLists.Models;
|
||||
|
||||
namespace FilterLists.Data
|
||||
{
|
||||
public class ListRepository : Repository<List>, IListRepository
|
||||
{
|
||||
public ListRepository(FilterListsContext context) : base(context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
using System.Collections.Generic;
|
||||
using FilterLists.Models;
|
||||
|
||||
namespace FilterLists.Data
|
||||
namespace FilterLists.Data.Repositories
|
||||
{
|
||||
public interface IRepository<T> where T : BaseEntity
|
||||
{
|
||||
13
api/FilterLists.Data/Repositories/ListRepository.cs
Normal file
13
api/FilterLists.Data/Repositories/ListRepository.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
using FilterLists.Data.Contexts;
|
||||
using FilterLists.Data.Contracts.Repositories;
|
||||
using FilterLists.Models;
|
||||
|
||||
namespace FilterLists.Data.Repositories
|
||||
{
|
||||
public class ListRepository : Repository<List>, IListRepository
|
||||
{
|
||||
public ListRepository(FilterListsDbContext context) : base(context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,17 +3,18 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FilterLists.Data.Contexts;
|
||||
using FilterLists.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FilterLists.Data
|
||||
namespace FilterLists.Data.Repositories
|
||||
{
|
||||
public class Repository<T> : IRepository<T> where T : BaseEntity
|
||||
{
|
||||
private readonly FilterListsContext _context;
|
||||
private readonly FilterListsDbContext _context;
|
||||
private readonly DbSet<T> _entities;
|
||||
|
||||
public Repository(FilterListsContext context)
|
||||
public Repository(FilterListsDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
_entities = context.Set<T>();
|
||||
|
|
@ -11,7 +11,7 @@ public class List : BaseEntity
|
|||
[StringLength(128)] [Column("email")] public string Email;
|
||||
[StringLength(512)] [Column("forum_url")] public string ForumUrl;
|
||||
[StringLength(512)] [Column("home_url")] public string HomeUrl;
|
||||
[Key] [Column("id")] public int Id;
|
||||
[Key] [Column("id")] public new int Id;
|
||||
[StringLength(512)] [Column("issues_url")] public string IssuesUrl;
|
||||
[StringLength(256)] [Column("name")] public string Name;
|
||||
[StringLength(512)] [Column("view_url")] public string ViewUrl;
|
||||
|
|
|
|||
12
api/FilterLists.Services/FilterLists.Services.csproj
Normal file
12
api/FilterLists.Services/FilterLists.Services.csproj
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp1.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\FilterLists.Data\FilterLists.Data.csproj" />
|
||||
<ProjectReference Include="..\FilterLists.Models\FilterLists.Models.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
10
api/FilterLists.Services/IListService.cs
Normal file
10
api/FilterLists.Services/IListService.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using System.Linq;
|
||||
using FilterLists.Models;
|
||||
|
||||
namespace FilterLists.Services
|
||||
{
|
||||
public interface IListService
|
||||
{
|
||||
IQueryable<List> Lists { get; }
|
||||
}
|
||||
}
|
||||
18
api/FilterLists.Services/ListService.cs
Normal file
18
api/FilterLists.Services/ListService.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using System.Linq;
|
||||
using FilterLists.Data.Repositories;
|
||||
using FilterLists.Models;
|
||||
|
||||
namespace FilterLists.Services
|
||||
{
|
||||
public class ListService : IListService
|
||||
{
|
||||
private readonly IRepository<List> _listRepository;
|
||||
|
||||
public ListService(IRepository<List> listRepository)
|
||||
{
|
||||
_listRepository = listRepository;
|
||||
}
|
||||
|
||||
public IQueryable<List> Lists => (IQueryable<List>) _listRepository.GetAll();
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FilterLists.Models", "Filte
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FilterLists.Data.Contracts", "FilterLists.Data.Contracts\FilterLists.Data.Contracts.csproj", "{07A5064E-1CB9-4990-84F8-25A9A89B1D45}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FilterLists.Services", "FilterLists.Services\FilterLists.Services.csproj", "{9F296ECF-97C9-47E6-A794-5AD900ECFE6C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -33,6 +35,10 @@ Global
|
|||
{07A5064E-1CB9-4990-84F8-25A9A89B1D45}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{07A5064E-1CB9-4990-84F8-25A9A89B1D45}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{07A5064E-1CB9-4990-84F8-25A9A89B1D45}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9F296ECF-97C9-47E6-A794-5AD900ECFE6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9F296ECF-97C9-47E6-A794-5AD900ECFE6C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9F296ECF-97C9-47E6-A794-5AD900ECFE6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9F296ECF-97C9-47E6-A794-5AD900ECFE6C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
|||
Loading…
Reference in a new issue