예제 #1
0
 internal OrderItem(long orderId, OrderItemProduct product, int count)
 {
     this.Id      = product.Id;
     this.OrderId = Checker.GTZero(orderId, nameof(orderId));
     this.Product = Checker.NotNull(product, nameof(product));
     this.Count   = Checker.GTZero(count, nameof(count));
     //this.Amount = product.Price * count;
 }
예제 #2
0
파일: Order.cs 프로젝트: zilianglei/Adnc
        /// <summary>
        /// 添加订单产品
        /// </summary>
        /// <param name="product"></param>
        /// <param name="count"></param>
        public void AddProduct(OrderItemProduct product, int count)
        {
            Checker.NotNull(product, nameof(product));
            Checker.GTZero(count, nameof(count));

            var existProduct = this.Items.FirstOrDefault(x => x.Product.Id == product.Id);

            if (existProduct == null)
            {
                this.Items.Add(new OrderItem(this.Id, product, count));
            }
            else
            {
                existProduct.ChangeCount(count);
            }
            this.Amount += product.Price * count;
        }