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:
@@ -0,0 +1,28 @@
|
||||
using ApplicationCore.Interfaces;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ApplicationCore.Specifications
|
||||
{
|
||||
public class BasketWithItemsSpecification : ISpecification<Basket>
|
||||
{
|
||||
public BasketWithItemsSpecification(int basketId)
|
||||
{
|
||||
BasketId = basketId;
|
||||
AddInclude(b => b.Items);
|
||||
}
|
||||
|
||||
public int BasketId { get; }
|
||||
|
||||
public Expression<Func<Basket, bool>> Criteria => b => b.Id == BasketId;
|
||||
|
||||
public List<Expression<Func<Basket, object>>> Includes { get; } = new List<Expression<Func<Basket, object>>>();
|
||||
|
||||
public void AddInclude(Expression<Func<Basket, object>> includeExpression)
|
||||
{
|
||||
Includes.Add(includeExpression);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user