public void CustomerInitialize() { if (!customerInitialied) { Customer lars = new Customer("anders", "Odensevej 17", 5000, "Odense", 23, 47583928, "*****@*****.**"); Customer jens = new Customer("jens", "Vejlevej 2", 5000, "Odense", 45, 83619374, "*****@*****.**"); customerList.Add(lars); customerList.Add(jens); listBCustomers.ItemsSource = customerList; customerInitialied = true; } }
//a customer gets added to the list, the list is refreshed and the customer is saved in the json customer file private void btnSaveUser_Click(object sender, RoutedEventArgs e) { try { Customer newCustomer = new Customer(txtNewUserFullName.Text, txtNewUserAdress.Text, int.Parse(txtNewUserZipCode.Text), txtNewUserCity.Text, age, int.Parse(txtNewUserTelehone.Text), txtNewUserEmail.Text); customerList.Add(newCustomer); listBCustomers.Items.Refresh(); //SaveCustomers(newCustomer); SaverAndLoader.ObjectToJsonString(customerList); ClearTextBoxes(); } catch { MessageBox.Show("Alle input skal være korrekt format!"); } }