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:
@@ -1,35 +1,14 @@
|
||||
using ApplicationCore.Interfaces;
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Collections.Generic;
|
||||
using ApplicationCore.Entities.OrderAggregate;
|
||||
using ApplicationCore.Entities.OrderAggregate;
|
||||
|
||||
namespace ApplicationCore.Specifications
|
||||
{
|
||||
public class CustomerOrdersWithItemsSpecification : ISpecification<Order>
|
||||
public class CustomerOrdersWithItemsSpecification : BaseSpecification<Order>
|
||||
{
|
||||
private readonly string _buyerId;
|
||||
|
||||
public CustomerOrdersWithItemsSpecification(string buyerId)
|
||||
: base(o => o.BuyerId == buyerId)
|
||||
{
|
||||
_buyerId = buyerId;
|
||||
AddInclude(o => o.OrderItems);
|
||||
AddInclude("OrderItems.ItemOrdered");
|
||||
}
|
||||
|
||||
public Expression<Func<Order, bool>> Criteria => o => o.BuyerId == _buyerId;
|
||||
|
||||
public List<Expression<Func<Order, object>>> Includes { get; } = new List<Expression<Func<Order, object>>>();
|
||||
public List<string> IncludeStrings { get; } = new List<string>();
|
||||
|
||||
public void AddInclude(Expression<Func<Order, object>> includeExpression)
|
||||
{
|
||||
Includes.Add(includeExpression);
|
||||
}
|
||||
|
||||
public void AddInclude(string includeString)
|
||||
{
|
||||
IncludeStrings.Add(includeString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user