Ejemplo n.º 1
0
        private void SaveOrder()
        {
            if (!_orderExists)
            {
                _order.OrderDate = DateTime.Now;

                foreach (ItemOptionsClass ioc in OrderItems)
                {
                    OrderItem oi = new OrderItem();
                    oi.Sku = ioc.Sku;
                    oi.Quantity = Int16.Parse(ioc.Quantity);
                    oi.OrderNum = _order.OrderNum;
                    context.OrderItems.InsertOnSubmit(oi);
                }

                context.Orders.InsertOnSubmit(_order);
            }
            else
            {
                foreach (ItemOptionsClass ioc in OrderItems)
                {
                    // add new items
                    OrderItem oi = new OrderItem();
                    oi.Sku = ioc.Sku;
                    oi.Quantity = Int16.Parse(ioc.Quantity);
                    oi.OrderNum = _order.OrderNum;
                    if (!context.OrderItems.Contains(oi))
                        context.OrderItems.InsertOnSubmit(oi);
                }

            }
            context.SubmitChanges();

            this.RaiseAndSetIfChanged(vm => vm.OrderNum, ref _orderNum, "");
            _hasChanges = false;
        }
 partial void UpdateOrderItem(OrderItem instance);
 partial void DeleteOrderItem(OrderItem instance);
 partial void InsertOrderItem(OrderItem instance);