Пример #1
0
 public virtual void AddProduct(Product product, double quantity, double discount = 0)
 {
     var orderDetails = new OrderDetails {Orders = this};
     orderDetails.SetProduct(product, quantity, discount);
     TotalValue += orderDetails.TotalPrice;
     OrderDetails.Add(orderDetails);
 }
 public virtual void SetProduct(Product product, double quantity, double discount = 0)
 {
     Product = product;
     Quantity = quantity;
     Discount = discount;
     TotalPrice = product.Price*quantity - discount;
 }
Пример #3
0
        public virtual bool RemoveProduct(Product product)
        {
            var orderDetails = OrderDetails.First(c => c.Product == product);
            if (orderDetails == null)
            {
                return false;
            }

            OrderDetails.Remove(orderDetails);
            TotalValue -= orderDetails.TotalPrice;

            return true;
        }