private void AddCustomer() { var customer = createCustomer(); string errorMessage = ""; try { if (customer.Name == "") { errorMessage = "Name cannot be empty"; throw new CustomerCheckValidationException(errorMessage); } if (customer.Address == "") { errorMessage = "Address cannot be empty"; throw new CustomerCheckValidationException(errorMessage); } if (customer.PostalCode == "") { errorMessage = "Postal code cannot be empty"; throw new CustomerCheckValidationException(errorMessage); } if (customer.Phone == "") { errorMessage = "Phonenumber cannot be empty"; throw new CustomerCheckValidationException(errorMessage); } pizzaManager.AddCustomer(customer); customerLabel.Text = string.Format("{0} have been added!", customer.Name); } catch (DbEntityValidationException ex) { foreach (var validations in ex.EntityValidationErrors) { foreach (var validation in validations.ValidationErrors) { customerLabel.Text += string.Format("There was an issue with: {0}", validation.PropertyName); } } } catch (CustomerCheckValidationException ex) { customerLabel.Text = ex.Message; } catch (Exception ex) { customerLabel.Text = string.Format("There was an issue with: {0}", ex.Message); } }