extract model interfaces, fix launch url

applicationUrl in launchSettings.json no longer allows specifying default path per https://github.com/aspnet/Announcements/issues/226
This commit is contained in:
Collin M. Barrett 2017-10-21 11:48:06 -05:00
parent e4aea30038
commit 791b744c05
16 changed files with 72 additions and 25 deletions

View file

@ -6,7 +6,7 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:49980/v1/lists"
"applicationUrl": "http://localhost:49980/"
}
}
}

View file

@ -29,8 +29,7 @@ public void Configure(IApplicationBuilder app)
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
app.UseMvc();
}).UseMvc();
}
}
}

View file

@ -1,4 +1,4 @@
using FilterLists.Data.Models;
using FilterLists.Data.Models.Implementations;
using Microsoft.EntityFrameworkCore;
namespace FilterLists.Data.Contexts

View file

@ -1,4 +1,4 @@
using FilterLists.Data.Models;
using FilterLists.Data.Models.Implementations;
using Microsoft.EntityFrameworkCore;
namespace FilterLists.Data.Contexts

View file

@ -0,0 +1,11 @@
using System;
namespace FilterLists.Data.Models.Contracts
{
public interface IBaseEntity
{
long Id { get; set; }
DateTime AddedDateUtc { get; set; }
DateTime? ModifiedDateUtc { get; set; }
}
}

View file

@ -0,0 +1,21 @@
using System;
namespace FilterLists.Data.Models.Contracts
{
public interface IList
{
string Name { get; set; }
string ViewUrl { get; set; }
string HomeUrl { get; set; }
string Description { get; set; }
string DescriptionSourceUrl { get; set; }
string Author { get; set; }
string ForumUrl { get; set; }
string IssuesUrl { get; set; }
string Email { get; set; }
string DonateUrl { get; set; }
long Id { get; set; }
DateTime AddedDateUtc { get; set; }
DateTime? ModifiedDateUtc { get; set; }
}
}

View file

@ -0,0 +1,13 @@
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; }
}
}

View file

@ -2,10 +2,11 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using FilterLists.Data.Models.Contracts;
namespace FilterLists.Data.Models
namespace FilterLists.Data.Models.Implementations
{
public abstract class BaseEntity
public abstract class BaseEntity : IBaseEntity
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]

View file

@ -1,8 +1,9 @@
using System.ComponentModel.DataAnnotations;
using FilterLists.Data.Models.Contracts;
namespace FilterLists.Data.Models
namespace FilterLists.Data.Models.Implementations
{
public class List : BaseEntity
public class List : BaseEntity, IList
{
[MaxLength(126)]
public string Name { get; set; }

View file

@ -1,8 +1,9 @@
using System.ComponentModel.DataAnnotations;
using FilterLists.Data.Models.Contracts;
namespace FilterLists.Data.Models
namespace FilterLists.Data.Models.Implementations
{
public class TableCsv : BaseEntity
public class TableCsv : BaseEntity, ITableCsv
{
[Required]
[MaxLength(126)]

View file

@ -1,11 +1,11 @@
using System.Collections.Generic;
using FilterLists.Data.Models;
using FilterLists.Data.Models.Contracts;
namespace FilterLists.Data.Repositories.Contracts
{
public interface IListRepository
{
IEnumerable<List> GetAll();
List GetByName(string listName);
IEnumerable<IList> GetAll();
IList GetByName(string listName);
}
}

View file

@ -1,11 +1,11 @@
using System.Collections.Generic;
using FilterLists.Data.Models;
using FilterLists.Data.Models.Contracts;
namespace FilterLists.Data.Repositories.Contracts
{
public interface ITableCsvRepository
{
IEnumerable<TableCsv> GetAll();
IEnumerable<ITableCsv> GetAll();
string GetUrlByName(string name);
}
}

View file

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using FilterLists.Data.Contexts;
using FilterLists.Data.Models;
using FilterLists.Data.Models.Contracts;
using FilterLists.Data.Repositories.Contracts;
namespace FilterLists.Data.Repositories.Implementations
@ -15,12 +15,12 @@ public ListRepository(FilterListsDbContext filterListsDbContext)
_filterListsDbContext = filterListsDbContext;
}
public IEnumerable<List> GetAll()
public IEnumerable<IList> GetAll()
{
return _filterListsDbContext.List.AsEnumerable();
}
public List GetByName(string listName)
public IList GetByName(string listName)
{
return _filterListsDbContext.List.First(x => x.Name == listName);
}

View file

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using FilterLists.Data.Contexts;
using FilterLists.Data.Models;
using FilterLists.Data.Models.Contracts;
using FilterLists.Data.Repositories.Contracts;
namespace FilterLists.Data.Repositories.Implementations
@ -15,7 +15,7 @@ public TableCsvRepository(FilterListsDbContext filterListsDbContext)
_filterListsDbContext = filterListsDbContext;
}
public IEnumerable<TableCsv> GetAll()
public IEnumerable<ITableCsv> GetAll()
{
return _filterListsDbContext.TableCsv.AsEnumerable();
}

View file

@ -1,10 +1,10 @@
using System.Collections.Generic;
using FilterLists.Data.Models;
using FilterLists.Data.Models.Contracts;
namespace FilterLists.Services.Contracts
{
public interface IListService
{
IEnumerable<List> GetAll();
IEnumerable<IList> GetAll();
}
}

View file

@ -1,5 +1,5 @@
using System.Collections.Generic;
using FilterLists.Data.Models;
using FilterLists.Data.Models.Contracts;
using FilterLists.Data.Repositories.Contracts;
using FilterLists.Services.Contracts;
@ -14,7 +14,7 @@ public ListService(IListRepository listRepository)
_listRepository = listRepository;
}
public IEnumerable<List> GetAll()
public IEnumerable<IList> GetAll()
{
return _listRepository.GetAll();
}