Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Commit

Permalink
Revert back Shopping cart rename
Browse files Browse the repository at this point in the history
  • Loading branch information
asvishnyakov committed Oct 29, 2020
1 parent 4e40b8d commit e149323
Show file tree
Hide file tree
Showing 23 changed files with 69 additions and 69 deletions.
2 changes: 1 addition & 1 deletion VirtoCommerce.Storefront.Model/Cart/Demo/ShoppingCart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace VirtoCommerce.Storefront.Model.Cart
{
public partial class CustomerOrder
public partial class ShoppingCart
{
[JsonRequired]
public LineItem[] UsualItems
Expand Down
6 changes: 3 additions & 3 deletions VirtoCommerce.Storefront.Model/Cart/Services/ICartBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ namespace VirtoCommerce.Storefront.Model.Cart.Services
/// </summary>
public interface ICartBuilder
{
CustomerOrder Cart { get; }
ShoppingCart Cart { get; }

/// <summary>
/// Capture cart and all next changes will be implemented on it
/// </summary>
/// <param name="cart"></param>
/// <returns></returns>
Task TakeCartAsync(CustomerOrder cart);
Task TakeCartAsync(ShoppingCart cart);

/// <summary>
/// Update shopping cart comment
Expand Down Expand Up @@ -133,7 +133,7 @@ public interface ICartBuilder
/// </summary>
/// <param name="cart"></param>
/// <returns></returns>
Task MergeWithCartAsync(CustomerOrder cart);
Task MergeWithCartAsync(ShoppingCart cart);

/// <summary>
/// Remove cart from service
Expand Down
10 changes: 5 additions & 5 deletions VirtoCommerce.Storefront.Model/Cart/Services/ICartService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace VirtoCommerce.Storefront.Model.Cart.Services
{
public interface ICartService
{
Task<IPagedList<CustomerOrder>> SearchCartsAsync(CartSearchCriteria criteria);
Task<CustomerOrder> SaveChanges(CustomerOrder cart);
Task<CustomerOrder> GetByIdAsync(string cartId);
Task<IPagedList<ShoppingCart>> SearchCartsAsync(CartSearchCriteria criteria);
Task<ShoppingCart> SaveChanges(ShoppingCart cart);
Task<ShoppingCart> GetByIdAsync(string cartId);
Task DeleteCartByIdAsync(string cartId);

Task<IEnumerable<ShippingMethod>> GetAvailableShippingMethodsAsync(CustomerOrder cart);
Task<IEnumerable<PaymentMethod>> GetAvailablePaymentMethodsAsync(CustomerOrder cart);
Task<IEnumerable<ShippingMethod>> GetAvailableShippingMethodsAsync(ShoppingCart cart);
Task<IEnumerable<PaymentMethod>> GetAvailablePaymentMethodsAsync(ShoppingCart cart);

}
}
6 changes: 3 additions & 3 deletions VirtoCommerce.Storefront.Model/Cart/ShoppingCart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

namespace VirtoCommerce.Storefront.Model.Cart
{
public partial class CustomerOrder : Entity, IDiscountable, IValidatable, IHasLanguage, ITaxable, ICacheKey
public partial class ShoppingCart : Entity, IDiscountable, IValidatable, IHasLanguage, ITaxable, ICacheKey
{
public CustomerOrder(Currency currency, Language language)
public ShoppingCart(Currency currency, Language language)
{
Currency = currency;
Language = language;
Expand Down Expand Up @@ -476,7 +476,7 @@ public override string ToString()

public override object Clone()
{
var result = base.Clone() as CustomerOrder;
var result = base.Clone() as ShoppingCart;

result.HandlingTotal = HandlingTotal?.Clone() as Money;
result.HandlingTotalWithTax = HandlingTotalWithTax?.Clone() as Money;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace VirtoCommerce.Storefront.Model.Cart
{
public class ShoppingCartSearchResult : GenericSearchResult<CustomerOrder>
public class ShoppingCartSearchResult : GenericSearchResult<ShoppingCart>
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace VirtoCommerce.Storefront.Model.Cart.Validators
{
public class AddCartItemValidator : AbstractValidator<AddCartItem>
{
public AddCartItemValidator(CustomerOrder cart)
public AddCartItemValidator(ShoppingCart cart)
{
RuleFor(x => x.Quantity).GreaterThan(0);
RuleFor(x => x.Product).NotNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace VirtoCommerce.Storefront.Model.Cart.Validators
{
public class CartDemoValidator : AbstractValidator<CustomerOrder>
public class CartDemoValidator : AbstractValidator<ShoppingCart>
{
public CartDemoValidator()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace VirtoCommerce.Storefront.Model.Cart.Validators
{
public class CartLineItemDemoValidator : AbstractValidator<LineItem>
{
public CartLineItemDemoValidator(CustomerOrder cart)
public CartLineItemDemoValidator(ShoppingCart cart)
{
RuleSet("strict", () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace VirtoCommerce.Storefront.Model.Cart.Validators
{
public class CartLineItemValidator : AbstractValidator<LineItem>
{
public CartLineItemValidator(CustomerOrder cart)
public CartLineItemValidator(ShoppingCart cart)
{
RuleSet("strict", () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace VirtoCommerce.Storefront.Model.Cart.Validators
{
public class CartShipmentValidator : AbstractValidator<Shipment>
{
public CartShipmentValidator(CustomerOrder cart, ICartService cartService)
public CartShipmentValidator(ShoppingCart cart, ICartService cartService)
{
RuleSet("strict", () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace VirtoCommerce.Storefront.Model.Cart.Validators
{
public class CartValidator : AbstractValidator<CustomerOrder>
public class CartValidator : AbstractValidator<ShoppingCart>
{
public CartValidator(ICartService cartService)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace VirtoCommerce.Storefront.Model.Cart.Validators
{
public class ChangeCartItemPriceValidator : AbstractValidator<ChangeCartItemPrice>
{
public ChangeCartItemPriceValidator(CustomerOrder cart)
public ChangeCartItemPriceValidator(ShoppingCart cart)
{
RuleFor(x => x.NewPrice).GreaterThanOrEqualTo(0);
RuleFor(x => x.LineItemId).NotNull().NotEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public PromotionEvaluationContext(Language language, Currency currency)
{
}

public Cart.CustomerOrder Cart { get; set; }
public Cart.ShoppingCart Cart { get; set; }
public IList<Product> Products { get; set; } = new List<Product>();
public Product Product { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ namespace VirtoCommerce.Storefront.Model.Order.Events
/// </summary>
public class OrderPlacedEvent : DomainEvent
{
public OrderPlacedEvent(WorkContext workContext, CustomerOrder order, Cart.CustomerOrder cart)
public OrderPlacedEvent(WorkContext workContext, CustomerOrder order, Cart.ShoppingCart cart)
{
WorkContext = workContext;
Cart = cart;
Order = order;
}
public WorkContext WorkContext { get; set; }
public Cart.CustomerOrder Cart { get; set; }
public Cart.ShoppingCart Cart { get; set; }
public CustomerOrder Order { get; set; }

}
Expand Down
4 changes: 2 additions & 2 deletions VirtoCommerce.Storefront.Model/WorkContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ public WorkContext()
/// <summary>
/// Gets or sets the current shopping cart
/// </summary>
public Lazy<Cart.CustomerOrder> CurrentCart { get; set; }
public Cart.CustomerOrder Cart => (CurrentCart?.IsValueCreated ?? false) ? CurrentCart.Value : null;
public Lazy<Cart.ShoppingCart> CurrentCart { get; set; }
public Cart.ShoppingCart Cart => (CurrentCart?.IsValueCreated ?? false) ? CurrentCart.Value : null;


/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public async Task ValidateShipment_RuleSetStrict_Valid()
{
//Arrange
var cartService = new Moq.Mock<ICartService>();
cartService.Setup(x => x.GetAvailableShippingMethodsAsync(It.IsAny<CustomerOrder>())).Returns(Task.FromResult(ShippingMethods));
cartService.Setup(x => x.GetAvailableShippingMethodsAsync(It.IsAny<ShoppingCart>())).Returns(Task.FromResult(ShippingMethods));
var cart = GetValidCart();

//Act
Expand All @@ -101,7 +101,7 @@ public async Task ValidateShipment_RuleSetStrict_UnavailableMethodError()
{
//Arrange
var cartService = new Moq.Mock<ICartService>();
cartService.Setup(x => x.GetAvailableShippingMethodsAsync(It.IsAny<CustomerOrder>())).Returns(Task.FromResult(ShippingMethods));
cartService.Setup(x => x.GetAvailableShippingMethodsAsync(It.IsAny<ShoppingCart>())).Returns(Task.FromResult(ShippingMethods));
var cart = GetValidCart();

var testShipments = new Faker<Shipment>()
Expand Down Expand Up @@ -137,7 +137,7 @@ public async Task ValidateShipment_RuleSetStrict_PriceError()
{
//Arrange
var cartService = new Moq.Mock<ICartService>();
cartService.Setup(x => x.GetAvailableShippingMethodsAsync(It.IsAny<CustomerOrder>())).Returns(Task.FromResult(ShippingMethods));
cartService.Setup(x => x.GetAvailableShippingMethodsAsync(It.IsAny<ShoppingCart>())).Returns(Task.FromResult(ShippingMethods));
var cart = GetValidCart();
var shipment = Faker.PickRandom( cart.Shipments );
shipment.Price = new Money(shipment.Price.Amount+1m, Usd);
Expand Down Expand Up @@ -488,7 +488,7 @@ public async Task ValidateCartLineItem_RuleSetStrict_PriceError()
}


private CustomerOrder GetValidCart()
private ShoppingCart GetValidCart()
{
var testItems = new Faker<LineItem>()
.CustomInstantiator(f => new LineItem(Usd, Language.InvariantLanguage))
Expand All @@ -505,8 +505,8 @@ private CustomerOrder GetValidCart()
.RuleFor(s => s.ShipmentMethodOption, (f, s) => ShippingMethods.FirstOrDefault(x=>x.ShipmentMethodCode == s.ShipmentMethodCode).OptionName)
.RuleFor(s => s.Price, (f,s) => ShippingMethods.FirstOrDefault(x => x.ShipmentMethodCode == s.ShipmentMethodCode).Price);

var testCart = new Faker<CustomerOrder>()
.CustomInstantiator(f => new CustomerOrder(Usd, Language.InvariantLanguage))
var testCart = new Faker<ShoppingCart>()
.CustomInstantiator(f => new ShoppingCart(Usd, Language.InvariantLanguage))
.RuleFor(c => c.Name, f => CART_NAME)
.RuleFor(c => c.CustomerId, f => Guid.NewGuid().ToString())
.RuleFor(c => c.CustomerName, f => f.Name.FullName())
Expand All @@ -517,10 +517,10 @@ private CustomerOrder GetValidCart()
return cart;
}

private CustomerOrder GetInvalidCart()
private ShoppingCart GetInvalidCart()
{
var testCart = new Faker<CustomerOrder>()
.CustomInstantiator(f => new CustomerOrder(Usd, Language.InvariantLanguage))
var testCart = new Faker<ShoppingCart>()
.CustomInstantiator(f => new ShoppingCart(Usd, Language.InvariantLanguage))
.RuleFor(c => c.Name, f => null)
.RuleFor(c => c.CustomerId, f => null);

Expand Down
4 changes: 2 additions & 2 deletions VirtoCommerce.Storefront/Controllers/Api/ApiCartController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ApiCartController(IWorkContextAccessor workContextAccessor, ICatalogServi
// Get current user shopping cart
// GET: storefrontapi/cart
[HttpGet]
public async Task<ActionResult<CustomerOrder>> GetCart()
public async Task<ActionResult<ShoppingCart>> GetCart()
{
var cartBuilder = await LoadOrCreateCartAsync();
await cartBuilder.ValidateAsync();
Expand Down Expand Up @@ -268,7 +268,7 @@ public async Task<ActionResult<Coupon>> ValidateCoupon([FromBody] Coupon coupon)
//Need lock to prevent concurrent access to same cart
using (await AsyncLock.GetLockByKey(WorkContext.CurrentCart.Value.GetCacheKey()).LockAsync())
{
await _cartBuilder.TakeCartAsync(WorkContext.CurrentCart.Value.Clone() as CustomerOrder);
await _cartBuilder.TakeCartAsync(WorkContext.CurrentCart.Value.Clone() as ShoppingCart);
_cartBuilder.Cart.Coupons = new[] { coupon };
await _cartBuilder.EvaluatePromotionsAsync();
return Ok(coupon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ApiListsController(IWorkContextAccessor workContextAccessor, ICatalogServ

// GET: storefrontapi/lists/{listName}/{type}
[HttpGet("{listName}/{type}")]
public async Task<ActionResult<CustomerOrder>> GetListByName([FromRoute]string listName, [FromRoute]string type)
public async Task<ActionResult<ShoppingCart>> GetListByName([FromRoute]string listName, [FromRoute]string type)
{
var unescapedListName = Uri.UnescapeDataString(listName);
using (await AsyncLock.GetLockByKey(GetAsyncListKey(WorkContext, unescapedListName, type)).LockAsync())
Expand Down Expand Up @@ -177,7 +177,7 @@ public async Task<ActionResult<ShoppingCartSearchResult>> SearchLists([FromBody]
// POST: storefrontapi/lists/{listName}/{type}/create
[HttpPost("{listName}/{type}/create")]
[ValidateAntiForgeryToken]
public async Task<ActionResult<CustomerOrder>> CreateList(string listName, string type)
public async Task<ActionResult<ShoppingCart>> CreateList(string listName, string type)
{
var cartBuilder = await LoadOrCreateCartAsync(Uri.UnescapeDataString(listName), type);
if (cartBuilder.Cart.IsTransient())
Expand Down
16 changes: 8 additions & 8 deletions VirtoCommerce.Storefront/Domain/Cart/CartBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public CartBuilder(IWorkContextAccessor workContextAccessor, ICartService cartSe

#region ICartBuilder Members

public virtual CustomerOrder Cart { get; protected set; }
public virtual ShoppingCart Cart { get; protected set; }

public virtual async Task TakeCartAsync(CustomerOrder cart)
public virtual async Task TakeCartAsync(ShoppingCart cart)
{
var store = _workContextAccessor.WorkContext.AllStores.FirstOrDefault(x => x.Id.EqualsInvariant(cart.StoreId));
if (store == null)
Expand Down Expand Up @@ -349,12 +349,12 @@ public virtual async Task AddOrUpdatePaymentAsync(Payment payment)
}
}

public virtual async Task MergeWithCartAsync(CustomerOrder cart)
public virtual async Task MergeWithCartAsync(ShoppingCart cart)
{
EnsureCartExists();

// Clone source cart to prevent its damage
cart = (CustomerOrder)cart.Clone();
cart = (ShoppingCart)cart.Clone();

// Reset primary keys for all aggregated entities before merge
// To prevent insertions same Ids for target cart
Expand Down Expand Up @@ -561,9 +561,9 @@ protected virtual CartSearchCriteria CreateCartSearchCriteria(string cartName, S
};
}

protected virtual CustomerOrder CreateCart(string cartName, Store store, User user, Language language, Currency currency, string type)
protected virtual ShoppingCart CreateCart(string cartName, Store store, User user, Language language, Currency currency, string type)
{
var cart = new CustomerOrder(currency, language)
var cart = new ShoppingCart(currency, language)
{
CustomerId = user.Id,
Name = cartName,
Expand Down Expand Up @@ -670,7 +670,7 @@ protected virtual void EnsureCartExists()
}
}

protected virtual async Task PrepareCartAsync(CustomerOrder cart, Store store)
protected virtual async Task PrepareCartAsync(ShoppingCart cart, Store store)
{
if (cart == null)
{
Expand All @@ -685,7 +685,7 @@ protected virtual async Task PrepareCartAsync(CustomerOrder cart, Store store)
await PrepareCartInternalAsync(cart, store);
}

protected virtual async Task PrepareCartInternalAsync(CustomerOrder cart, Store store)
protected virtual async Task PrepareCartInternalAsync(ShoppingCart cart, Store store)
{
//Load products for cart line items
if (cart.Items.Any())
Expand Down
4 changes: 2 additions & 2 deletions VirtoCommerce.Storefront/Domain/Cart/CartCacheRegion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static IChangeToken CreateCustomerChangeToken(string customerId)
}


public static IChangeToken CreateChangeToken(CustomerOrder cart)
public static IChangeToken CreateChangeToken(ShoppingCart cart)
{
if (cart == null)
{
Expand All @@ -34,7 +34,7 @@ public static IChangeToken CreateChangeToken(CustomerOrder cart)
return new CompositeChangeToken(new[] { CreateChangeToken(), new CancellationChangeToken(cancellationTokenSource.Token) });
}

public static void ExpireCart(CustomerOrder cart)
public static void ExpireCart(ShoppingCart cart)
{
if (cart != null)
{
Expand Down
Loading

0 comments on commit e149323

Please sign in to comment.