示例#1
0
 void OrderSaved(object sender, DataEventArgs <OrderPresentationModel> e)
 {
     if (e != null && e.Value != null)
     {
         OrderPresentationModel order = e.Value;
         if (Orders.Contains(order))
         {
             order.Saved -= OrderSaved;
             commandProxy.SaveAllOrdersCommands.UnregisterCommand(order.SaveOrderCommand);
             Orders.Remove(order);
         }
     }
 }
 private void PopulateOrders()
 {
     foreach (Services.Order order in ordersRepository.GetOrdersToEdit())
     {
         var orderPresentationModel = new OrderPresentationModel()
                                          {
                                              OrderName = order.Name,
                                              DeliveryDate = order.DeliveryDate
                                          };
         orderPresentationModel.Saved += OrderSaved;
         commandProxy.SaveAllOrdersCommands.RegisterCommand(orderPresentationModel.SaveOrderCommand);
         Orders.Add(orderPresentationModel);
     }
 }
 private void OrderSaved(object sender, DataEventArgs <OrderPresentationModel> e)
 {
     if (e != null && e.Value != null)
     {
         OrderPresentationModel order = e.Value;
         if (this.Orders.Contains(order))
         {
             order.Saved -= this.OrderSaved;
             //TODO: 05 - As each order is saved, it is unregistered from the application's SaveAll command.
             this.commandProxy.SaveAllOrdersCommand.UnregisterCommand(order.SaveOrderCommand);
             // Remove saved orders from the collection.
             this._orders.Remove(order);
         }
     }
 }
        private void PopulateOrders()
        {
            foreach (Services.Order order in this.ordersRepository.GetOrdersToEdit())
            {
                var orderPresentationModel = new OrderPresentationModel()
                {
                    OrderName    = order.Name,
                    DeliveryDate = order.DeliveryDate
                };
                orderPresentationModel.Saved += this.OrderSaved;
                this.commandProxy.SaveAllOrdersCommand.RegisterCommand(orderPresentationModel.SaveOrderCommand);
                this.Orders.Add(orderPresentationModel);
            }

            this.SelectedOrder = this.Orders[0];
        }
        private void PopulateOrders()
        {
            _orders = new ObservableCollection <OrderPresentationModel>();

            foreach (Services.Order order in this.ordersRepository.GetOrdersToEdit())
            {
                // Wrap the Order object in a presentation model object.
                var orderPresentationModel = new OrderPresentationModel(order);
                _orders.Add(orderPresentationModel);

                // Subscribe to the Save event on the individual orders.
                orderPresentationModel.Saved += this.OrderSaved;

                //TODO: 04 - Each Order Save command is registered with the application's SaveAll command.
                commandProxy.SaveAllOrdersCommand.RegisterCommand(orderPresentationModel.SaveOrderCommand);
            }
        }
        private void PopulateOrders()
        {
            _orders = new ObservableCollection<OrderPresentationModel>();

            foreach ( Services.Order order in this.ordersRepository.GetOrdersToEdit() )
            {
                // Wrap the Order object in a presentation model object.
                var orderPresentationModel = new OrderPresentationModel( order );
                _orders.Add( orderPresentationModel );

                // Subscribe to the Save event on the individual orders.
                orderPresentationModel.Saved += this.OrderSaved;

                //TODO: 04 - Each Order Save command is registered with the application's SaveAll command.
                commandProxy.SaveAllOrdersCommand.RegisterCommand( orderPresentationModel.SaveOrderCommand );
            }
        }
 private void OrderSaved(object sender, DataEventArgs <OrderPresentationModel> e)
 {
     if (e != null && e.Value != null)
     {
         OrderPresentationModel order = e.Value;
         if (this.Orders.Contains(order))
         {
             order.Saved -= this.OrderSaved;
             this.commandProxy.SaveAllOrdersCommand.UnregisterCommand(order.SaveOrderCommand);
             this.Orders.Remove(order);
             if (this.Orders.Count > 0)
             {
                 this.SelectedOrder = this.Orders[0];
             }
         }
     }
 }
 private void OrderSaved(object sender, DataEventArgs<OrderPresentationModel> e)
 {
     if (e != null && e.Value != null)
     {
         OrderPresentationModel order = e.Value;
         if (this.Orders.Contains(order))
         {
             order.Saved -= this.OrderSaved;
             this.commandProxy.SaveAllOrdersCommand.UnregisterCommand(order.SaveOrderCommand);
             this.Orders.Remove(order);
             if (this.Orders.Count > 0)
             {
                 this.SelectedOrder = this.Orders[0];
             }
         }
     }
 }