Example #1
0
 public CustomerDetailsView(CustomerDetailsVM customerVM)
 {
     InitializeComponent();
     customerVM.View             = this;
     this.DataContext            = customerVM;
     cmbContactTypes.ItemsSource = customerVM.ContactTypes;
 }
Example #2
0
        protected override void EditDataItem(object parameter)
        {
            CustomerDetailsVM customerVM = new CustomerDetailsVM(SelectedItem.Id);

            customerVM.CustomerModified += ModifyList;
            CustomerDetailsView customerDetailsView = new CustomerDetailsView(customerVM);

            customerDetailsView.Show();
        }
Example #3
0
        // After a creation or modification of a customer from the details view, modify the data list
        // so we don't need to re-read all the customers from the database
        private void ModifyList(object sender, EventArgs e)
        {
            CustomerDetailsVM newCustomer = (CustomerDetailsVM)sender;
            CustomerItemVM    newItem     = new CustomerItemVM
            {
                Id          = newCustomer.Customer.Id,
                FirstName   = newCustomer.Customer.FirstName,
                LastName    = newCustomer.Customer.LastName,
                DateOfBirth = newCustomer.Customer.DateOfBirth,
                CompanyName = DB.GetCompany(newCustomer.Customer.CompanyId)?.Name
            };
            int index = data.IndexOf(newItem);

            if (index >= 0)
            {
                data[index] = newItem;
            }
            else
            {
                data.Add(newItem);
            }
        }