Ejemplo n.º 1
0
        private void AddCustomerButton_OnClick(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            var    dialog = new AddModifyCustomerDialog();

            dialog.Owner = this;
            dialog.ShowDialog();
            if (dialog.DialogResult == true)
            {
                var customer = dialog.Customer;
                _viewModel.customerRepository.AddNewCustomer(customer);
                _viewModel.Customers.Add(customer);
            }
        }
Ejemplo n.º 2
0
        private void EditCustomerButton_OnClick(object sender, RoutedEventArgs e)
        {
            Button   button = sender as Button;
            Customer copy   = new Customer(button.DataContext as Customer);
            var      dialog = new AddModifyCustomerDialog(copy);

            dialog.Owner = this;
            dialog.ShowDialog();
            if (dialog.DialogResult == true)
            {
                for (int i = 0; i < _viewModel.Customers.Count; i++)
                {
                    if (_viewModel.Customers[i].CustomerId == copy.CustomerId)
                    {
                        _viewModel.customerRepository.ChangeCustomer(_viewModel.Customers[i], copy);
                        _viewModel.Customers[i] = copy;
                    }
                }
            }
        }