private static void emptyTableContact() { ContactService contactSrv = new ContactService(); contactSrv.emptyTable(); List<ContactBO> contacts = contactSrv.getAllFromTable(); Assert.AreEqual(0, contacts.Count(), string.Format("'Contact' Table should be empty.")); }
/// <remarks> /// Displays customer details and contacts if any customer is selected in table /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void listCustomers_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (listCustomers.SelectedItem != null) { CustomerBO selectedCustomer = (CustomerBO)listCustomers.SelectedItem; lblCompanyName.Content = selectedCustomer.CompanyName; lblContactPerson.Content = selectedCustomer.ContactPerson; ContactService contactSrv = new ContactService(); List<ContactBO> customerContacts = contactSrv.getAllFromTableByCustomerID(selectedCustomer.CustomerID); ContactTypeService contactTypeSrv = new ContactTypeService(); //adding ContactType Name to ContactBO Obj. by ContactType ID foreach (ContactBO customerContact in customerContacts) { customerContact.ContactTypeName = contactTypeSrv.getNameById(customerContact.ContactTypeID); } listContacts.ItemsSource = customerContacts; } }
/// <remarks> /// Fills the Booking detailed view on bottom of the page with the _selectedBooking info. /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void UnconfBookingsGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { CultureInfo culture = new CultureInfo("de-DE"); _selectedBooking = (BookingBO)UnconfBookingsGrid.SelectedItem; // if there is a booking with active selection in the DataGrid, textBlocks are filled with booking info if (_selectedBooking != null) { txtID.Text = _selectedBooking.BookingID.ToString(); txtDate.Text = _selectedBooking.Date.ToString("d", culture); txtRoom.Text = _selectedBooking.Room; txtParticipants.Text = _selectedBooking.Participants.ToString(); txtCustomer.Text = _selectedBooking.CustomerCompany; txtCustomerPIC.Text = _selectedBooking.CustomerContactPerson; txtCreated.Text = _selectedBooking.Created.ToString("d", culture); txtAdmin.Text = _selectedBooking.Admin; txtAdditional.Text = _selectedBooking.AdditionalInfo; //in ideal world must never execute first condition if (_selectedBooking.Confirmed != null) { txtConfirmed.Text = ((DateTime)_selectedBooking.Confirmed).ToString("g", culture); } else txtConfirmed.Text = "";// must always execute this condition, as this is Unconfirmed Booking View // displays first available contact value, if there is any in the table ContactService contactSrv = new ContactService(); List<ContactBO> contacts = contactSrv.getAllFromTableByCustomerID(_selectedBooking.CustomerID); if (contacts.Count > 0) { txtContact.Text = contacts[0].Value.ToString(); } else txtContact.Text = ""; } }
/// <remarks> /// updates existing contact entry with updated information from contactType combobox and value textbox /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void btnChangeContact_Click(object sender, RoutedEventArgs e) { // check if contactType is selected 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; // check if contactType is selected ContactBO listContact = (ContactBO)listContacts.SelectedItem; if (null == listContact) { txtError.Content = "palun valige kontakt."; return; } int thisContactID = listContact.ContactID; // if new information is provided by customer, update the existing BO with new information, else, display warning if (!String.IsNullOrEmpty(valueToAdd)) { ContactService contactSrv = new ContactService(); contactSrv.UpdateById(thisContactID, thisCustomerID, sellectedContactTypeID, valueToAdd, DateTime.Now); updateListContacts(); txtContactTypeValue.Text = ""; } else { txtError.Content = "Väärtus on tühi!"; } }
/// <remarks> /// updates Customer Contact list after adding/updating contacts. /// </remarks> private void updateListContacts() { ContactTypeService contactTypeSrv = new ContactTypeService(); ContactService contactSrv = new ContactService(); List<ContactBO> customerContacts = contactSrv.getAllFromTableByCustomerID(_selectedCustomer.CustomerID); //adding ContactType Name to ContactBO Obj. by ContactType ID foreach (ContactBO customerContact in customerContacts) { customerContact.ContactTypeName = contactTypeSrv.getNameById(customerContact.ContactTypeID); } listContacts.ItemsSource = customerContacts; }
/// <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.")); }