Beispiel #1
0
 internal OrderViewModel(OrderDto orderDto)
 {
     OrderId = orderDto.OrderId;
     _description = orderDto.Description;
     _quantity = orderDto.Quantity.ToString(CultureInfo.InvariantCulture);
     _originalValue = (OrderViewModel)MemberwiseClone(); //Undo op
     _orderServiceManager = ServiceLocator.ServiceProvider.Instance.Get<IOrderServiceManager>();
 }
Beispiel #2
0
 private void BtnAddOrderClick(object sender, RoutedEventArgs e)
 {
     OrderView view = new OrderView();
     OrderViewModel order = new OrderViewModel(ServiceProvider.Instance.Get<IOrderServiceManager>())
                                {
                                    Customer = (CustomerViewModel)DataContext,
                                    Mode = Mode.Add
                                };
     view.DataContext = order;
     view.ShowDialog();
 }
Beispiel #3
0
        internal void GetOrders()
        {
            ObservableCollection<OrderViewModel> temp = new ObservableCollection<OrderViewModel>();

            _orderServiceManager.GetOrders(CustomerId, (response, exception) =>
                                                                                  {
                                                                                      if (exception == null)
                                                                                      {
                                                                                          foreach (OrderDto orderDto in response.Orders)
                                                                                          {
                                                                                              OrderViewModel order = new OrderViewModel(orderDto)
                                                                                              {
                                                                                                  Customer = this
                                                                                              };
                                                                                              temp.Add(order);
                                                                                          }
                                                                                          Orders = temp;
                                                                                      }

                                                                                  });
        }
Beispiel #4
0
        private void Update()
        {
            if (Mode == Mode.Add)
            {
                _orderServiceManager.AddOrder(Customer.CustomerId, new OrderDto
                {
                    Description = Description,
                    Quantity = int.Parse(Quantity)
                });
                Customer.GetOrders();
            }
            else if (Mode == Mode.Edit)
            {
                _orderServiceManager.UpdateOrder(new OrderDto
                                {
                                    OrderId = OrderId,
                                    Description = Description,
                                    Quantity = int.Parse(Quantity)
                                });

                _originalValue = (OrderViewModel)MemberwiseClone();//undo op
            }
        }