protected void EditPurchaseOrder(PurchaseOrder order)
        {
            order.Title   += "_update";
            order.Customer = Customer.Create(10);

            foreach (var item in order.PurchaseItems)
            {
                item.Number *= 10;
                item.Product = Product.Create(10);
            }

            var newItem   = PurchaseItem.Create(order.GetNewItemNo());
            var firstItem = order.PurchaseItems.First();

            newItem.Number  = firstItem.Number;
            newItem.Product = firstItem.Product;

            order.AddItem(newItem);
            order.RemoveItem(firstItem);
        }
Example #2
0
        private IEnumerable <PurchaseOrder> CreatePurchaseOrders(int number, int maxItemNumber, int maxCutomerId, int maxProductId)
        {
            for (int i = 0; i < number; i++)
            {
                PurchaseOrder order = PurchaseOrder.Create(0);

                order.Title    = $"{nameof(order.Title)}_{i + 1}";
                order.Customer = Customer.Create((i % maxCutomerId) + 1);

                for (int ii = 0; ii < maxItemNumber; ii++)
                {
                    var orderItem = PurchaseItem.Create(order.GetNewItemNo());
                    orderItem.Product = Product.Create((ii % maxProductId) + 1);
                    orderItem.Number  = orderItem.PurchaseItemNo;

                    order.AddItem(orderItem);
                }

                yield return(order);
            }
        }