Using Base Specification Class (#56)

* Ardalis/upgrade1 (#44)

* Upgrading to netcore 2.0
Updating repository to support async options and refactoring to use it.

* Starting work on tracking customer orders feature.

* Cleaning up some bugs
Working on basket view component implementation

* Fixing up styles, especially for basket in header.

* Adding Order Features (#47)

* Working on order model binding from checkout page - WIP

* Small layout tweaks (#43)

* Updating quantities implemented.

* Fixed basket widget count

* Order History (#49)

* working on creating and viewing orders.
* Working on wiring up listing of orders
* List orders page works as expected. Needed to support ThenInclude scenarios. Currently using strings.

* Remove non-icon basket link from header
Add comments to EF query logic

* Refactoring to use base specification type

* minor cleanup
This commit is contained in:
Steve Smith
2017-10-18 13:18:25 -04:00
committed by GitHub
parent d52dbb1915
commit 964173f277
7 changed files with 47 additions and 76 deletions

View File

@@ -1,39 +1,18 @@
using ApplicationCore.Interfaces;
using Microsoft.eShopWeb.ApplicationCore.Entities;
using System;
using System.Linq.Expressions;
using System.Collections.Generic;
using ApplicationCore.Entities.OrderAggregate;
using Microsoft.eShopWeb.ApplicationCore.Entities;
namespace ApplicationCore.Specifications
{
public class BasketWithItemsSpecification : ISpecification<Basket>
public class BasketWithItemsSpecification : BaseSpecification<Basket>
{
public BasketWithItemsSpecification(int basketId)
:base(b => b.Id == basketId)
{
BasketId = basketId;
AddInclude(b => b.Items);
}
public BasketWithItemsSpecification(string buyerId)
:base(b => b.BuyerId == buyerId)
{
BuyerId = buyerId;
AddInclude(b => b.Items);
}
public int? BasketId { get; }
public string BuyerId { get; }
public Expression<Func<Basket, bool>> Criteria => b =>
(BasketId.HasValue && b.Id == BasketId.Value)
|| (BuyerId != null && b.BuyerId == BuyerId);
public List<Expression<Func<Basket, object>>> Includes { get; } = new List<Expression<Func<Basket, object>>>();
public List<string> IncludeStrings { get; } = new List<string>();
public void AddInclude(Expression<Func<Basket, object>> includeExpression)
{
Includes.Add(includeExpression);
}
}
}