Refactoring and Adding Tests (#28)
* Introducing repository and refactoring services. Changing entities to use int keys everywhere. * Refactoring application services to live in web project and only reference repositories, not EF contexts. * Cleaning up implementations * Moving logic out of CatalogController Moving entity knowledge out of viewmodels. * Implementing specification includes better for catalogservice * Cleaning up and adding specification unit tests
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
namespace ApplicationCore.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// This type eliminates the need to depend directly on the ASP.NET Core logging types.
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public interface IAppLogger<T>
|
||||
{
|
||||
void LogWarning(string message, params object[] args);
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ApplicationCore.Interfaces
|
||||
{
|
||||
public interface IBasketService
|
||||
{
|
||||
Task<Basket> GetBasket(string basketId);
|
||||
Task<Basket> CreateBasket();
|
||||
Task<Basket> CreateBasketForUser(string userId);
|
||||
|
||||
Task AddItemToBasket(Basket basket, int productId, int quantity);
|
||||
//Task UpdateBasket(Basket basket);
|
||||
}
|
||||
}
|
||||
18
src/ApplicationCore/Interfaces/IRepository.cs
Normal file
18
src/ApplicationCore/Interfaces/IRepository.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace ApplicationCore.Interfaces
|
||||
{
|
||||
|
||||
public interface IRepository<T> where T : BaseEntity
|
||||
{
|
||||
T GetById(int id);
|
||||
List<T> List();
|
||||
List<T> List(ISpecification<T> spec);
|
||||
T Add(T entity);
|
||||
void Update(T entity);
|
||||
void Delete(T entity);
|
||||
}
|
||||
}
|
||||
13
src/ApplicationCore/Interfaces/ISpecification.cs
Normal file
13
src/ApplicationCore/Interfaces/ISpecification.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace ApplicationCore.Interfaces
|
||||
{
|
||||
public interface ISpecification<T>
|
||||
{
|
||||
Expression<Func<T, bool>> Criteria { get; }
|
||||
List<Expression<Func<T, object>>> Includes { get; }
|
||||
void AddInclude(Expression<Func<T, object>> includeExpression);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
namespace ApplicationCore.Interfaces
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ApplicationCore.Interfaces
|
||||
{
|
||||
|
||||
public interface IUriComposer
|
||||
|
||||
Reference in New Issue
Block a user