/// <remarks> /// Validates user input and if OK, stores new CustomerBO in DB /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void btnConfirm_Click(object sender, RoutedEventArgs e) { txtErrorCustomer.Content = ""; string txtCompanyNameToAdd = txtCompanyName.Text; string txtCompanyContactNameToAdd = txtCompanyContactName.Text; if (String.IsNullOrEmpty(txtCompanyNameToAdd)) { txtErrorCustomer.Content = "'Organisatsioon:' Väärtus on tühi!"; return; } if (String.IsNullOrEmpty(txtCompanyContactNameToAdd)) { txtErrorCustomer.Content = "'Kontaktisik:' Väärtus on tühi!"; return; } CustomerService customerSrv = new CustomerService(); int newCustomerId = customerSrv.addNew(txtCompanyNameToAdd, txtCompanyContactNameToAdd); if (0 == newCustomerId) { txtErrorCustomer.Content = "Klient ei ole loodud! Proovi uuesti!"; return; } txtErrorCustomer.Content = ""; //GoTo CustomerUpdateV with freshly stored customer details CustomerBO customer = customerSrv.getCustomerById(newCustomerId); this.NavigationService.Navigate(new CustomerUpdateV(customer, true)); }
private static void fullFillCustomerTable() { CustomerService customerSrv = new CustomerService(); customerSrv.addNew("ABC OÜ", "Anne"); customerSrv.addNew("XYZ AS", "Daria"); List<CustomerBO> customers = customerSrv.getAllFromTable(); Assert.AreNotEqual(0, customers.Count(), string.Format("There should be values in 'Customer' Table.")); }