Implemented shopping carts functionality elements
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
namespace LiteCharms.Features.ShoppingCarts.Commands;
|
||||
|
||||
public class AddItemToShoppingCartCommand : IRequest<Result>
|
||||
{
|
||||
public Guid ShoppingCartId { get; set; }
|
||||
|
||||
public Guid ProductPriceId { get; set; }
|
||||
|
||||
public int Quantity { get; set; }
|
||||
|
||||
private AddItemToShoppingCartCommand(Guid shoppingCartId, Guid productPriceId, int quantity = 1)
|
||||
{
|
||||
ShoppingCartId = shoppingCartId;
|
||||
ProductPriceId = productPriceId;
|
||||
Quantity = quantity;
|
||||
}
|
||||
|
||||
public static AddItemToShoppingCartCommand Create(Guid shoppingCartId, Guid productPriceId, int quantity = 1)
|
||||
{
|
||||
if (shoppingCartId == Guid.Empty)
|
||||
throw new ArgumentException($"Shopping cart ID is required", nameof(shoppingCartId));
|
||||
|
||||
if (productPriceId == Guid.Empty)
|
||||
throw new ArgumentException($"Product item required", nameof(productPriceId));
|
||||
|
||||
if(quantity <= 0) throw new ArgumentException($"Quantity must be at least 1", nameof(quantity));
|
||||
|
||||
return new(shoppingCartId, productPriceId, quantity);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user