コード例 #1
0
 public Order UpdateOrder(Order order)
 {
     if (_context.Orders.Local.All(o => o.Id != order.Id))
     {
         _context.Orders.Attach(order);
     }
     //_context.Entry(order).State = EntityState.Modified;
     _context.SaveChanges();
     return order;
 }
コード例 #2
0
 public Order AddOrder(Order order)
 {
     _context.Orders.Add(order);
     _context.SaveChanges();
     return order;
 }
コード例 #3
0
        private void OnChangeSelectedCustomer(CustomerWrapper selectedCustomer)
        {
            selectedCustomer.Orders =
                    new ObservableCollection<OrderWrapper>(
                        _ordersRepository.GetAllOrders().Where(o => o.CustomerId == SelectedCustomer.Id).Select(
                            x => new OrderWrapper(x)));

            var order = new Order
                            {
                                CustomerId = selectedCustomer.Id,
                                ItemsTotal = 1,
                                OrderDate = DateTime.Now,
                                StoreId = selectedCustomer.StoreId,
                                Phone = SelectedCustomer.Phone,
                                DeliveryCity = SelectedCustomer.City,
                                DeliveryState = selectedCustomer.State,
                                DeliveryStreet = selectedCustomer.Street,
                                DeliveryZip = selectedCustomer.Zip,
                                DeliveryDate = DateTime.Now.AddDays(2)
                            };

            NewOrder = new OrderWrapper(order);
        }