public ProductViewModel(Product product) { Id = product.Id; Category = product.Category.Name; Code = product.ProductCode; Name = product.Name; Price = product.Price; Thumbnail = GetThumbnailUrl(product.ProductCode); }
public virtual void AddToCart(Product product) { Guard.Against<ArgumentNullException>(product == null, "Cannot add a null Product to the cart. " + "The ShoppingCart expects a valid non-null Product instance."); var existingItem = Items.SingleOrDefault(x => x.ProductId == product.Id); if (existingItem != null) { existingItem.Quantity++; return; } _items.Add(new ShoppingCartItem(this) { ProductId = product.Id, ProductName = product.Name, ProductCategory = product.Category.Name, ProductCode = product.ProductCode, Price = product.Price, Quantity = 1 }); UpdateModified(); }