public void AddItem(Guid commodityID, Quantity quantity) { var item=this.Items.FirstOrDefault(p=>p.CommodityID==commodityID); if(item==null) { item=new DistributionVoucherItem(); } item.CommodityID=commodityID; item.Quantity=quantity; }
public void RemoveItem(Guid commodityID,Quantity quantity) { var item=this.Items.FirstOrDefault(p => p.CommodityID == commodityID); if (item == null) throw new DomainException("订单中无此物品"); this.Items.Remove(item); }
public void AddItem(Guid commodityID,Quantity quantity,decimal price,string remark) { var item=new SaleOrderItem(){CommodityID=commodityID,Quantity=quantity,Price=price,Remark=remark}; this.Items.Add(item); }
private void UpdateItem(Guid itemID,Guid commodityID,Quantity quantity,decimal price,string remark) { if (itemID == Guid.Empty) throw new ArgumentException("参数不含主键"); var existingSaleOrderItem = this.Items.FirstOrDefault(p => p.ID == itemID); if (existingSaleOrderItem == null) throw new DomainException("无此主键实体"); existingSaleOrderItem.CommodityID = commodityID; existingSaleOrderItem.Quantity = quantity; existingSaleOrderItem.Price = price; existingSaleOrderItem.Remark = remark; }