private bool CheckEMailforUnique(EMailAddress eMailAddress) { for (int i = 0; i < CustomerList.Count; i++) { if (eMailAddress.getEmailAddress() == CustomerList[i]._eMail.getEmailAddress()) { return(false); } } return(true); }
/// <summary> /// add a new customer to list /// </summary> /// <param name="customer"></param> public void AddCustomer(string firstName, string lastName, EMailAddress eMailAddress, float moneyBalance, Address address) { if (CustomerList == null) { CustomerList = new List <Customer>(); } int customerNumber = CheckCustomerNumberorFindOne(CustomerList.Count + 1); if (eMailAddress.getEmailAddress() == String.Empty || CheckEMailforUnique(eMailAddress) == false) { MessageBox.Show("Wrong input of the E-Mail address or the E-Mail address already exit"); return; } else { Customer customer = new Customer(firstName, lastName, eMailAddress, customerNumber, moneyBalance, DateTime.Now, address); CustomerList.Add(customer); _mainView.UpdateDataGridViewOverview(CustomerList); _mainView.UpdateDatagridViewFullList(CustomerList); } }