/// <remarks> /// Adds new contact entry with data provided by customer. /// Validates presence of user input before saving. /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddContact_Click(object sender, RoutedEventArgs e) { txtError.Content = ""; ContactTypeBO cboxContact = (ContactTypeBO)cboxContacts.SelectedItem; if (null == cboxContact) { txtError.Content = "palun valige liik."; return; } int sellectedContactTypeID = cboxContact.ContactTypeID; int thisCustomerID = _selectedCustomer.CustomerID; string valueToAdd = txtContactTypeValue.Text; if (!String.IsNullOrEmpty(valueToAdd)) { ContactService contactSrv = new ContactService(); contactSrv.addNew(thisCustomerID, sellectedContactTypeID, valueToAdd, DateTime.Now); updateListContacts(); txtContactTypeValue.Text = ""; } else { txtError.Content = "Väärtus on tühi!"; } }
private static void fullFillContactTable() { ContactTypeService contactTypeSrv = new ContactTypeService(); List<ContactTypeBO> contactTypes = contactTypeSrv.getAllFromTable(); Assert.AreNotEqual(0, contactTypes.Count(), string.Format("There should be values in 'ContactType' Table.")); int existingContactTypeID = contactTypes.ElementAt(0).ContactTypeID; CustomerService customerSrv = new CustomerService(); List<CustomerBO> customers = customerSrv.getAllFromTable(); Assert.AreNotEqual(0, customers.Count(), string.Format("There should be values in 'Customer' Table.")); int existingCustomerID = customers.ElementAt(0).CustomerID; //TODO: Verify that contact cannot be created before Customer (CustomerID foreign key) //TODO: Verify that contact cannot be created before ContactType (ContactTypeID foreign key) ContactService contactSrv = new ContactService(); contactSrv.addNew(existingCustomerID, existingContactTypeID, "val_skype", DateTime.Now);//TODO: take first from list contactSrv.addNew(existingCustomerID, existingContactTypeID, "val_mail", DateTime.Now); contactSrv.addNew(existingCustomerID, existingContactTypeID, "val_phone", DateTime.Now); List<ContactBO> contacts = contactSrv.getAllFromTable(); Assert.AreNotEqual(0, contacts.Count(), string.Format("There should be values in 'Contact' Table.")); }