/// <summary> /// NAME: Austin Gee /// DATE: 4/28/2020 /// CHECKED BY: /// /// This method inserts a customer /// </summary> /// <remarks> /// UPDATED BY: NA /// UPDATE DATE: NA /// WHAT WAS CHANGED: NA /// /// </remarks> /// <param name="customer"></param> /// <returns></returns> public int InsertAdoptionCustomer(AdoptionCustomer customer) { int rows = 0; var conn = DBConnection.GetConnection(); var cmd = new SqlCommand("sp_insert_customer", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Email", customer.CustomerEmail); cmd.Parameters.AddWithValue("@FirstName", customer.FirstName); cmd.Parameters.AddWithValue("@LastName", customer.LastName); cmd.Parameters.AddWithValue("@PhoneNumber", customer.PhoneNumber); cmd.Parameters.AddWithValue("@addressLineOne", customer.AddressLineOne); cmd.Parameters.AddWithValue("@addressLineTwo", customer.AddressLineTwo); cmd.Parameters.AddWithValue("@City", customer.City); cmd.Parameters.AddWithValue("@State", customer.State); cmd.Parameters.AddWithValue("@Zipcode", customer.Zipcode); try { conn.Open(); var reader = cmd.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } finally { conn.Close(); } return(rows); }
/// <summary> /// Creator: Awaab Elamin /// Created: 2020/02/04 /// Approver : Mohamed Elamin /// after reviewer select a customer record, btnOpenRecord retrireve that customer data and filled /// the customer details and hidden the adoption appliaction then show the customer data /// </summary> /// <param name="e"></param> /// <param name="sender"></param> private void btnOpenRecord_Click(object sender, RoutedEventArgs e) { List <Questionnair> questionnairs = new List <Questionnair>(); try { adoptionApplication = (AdoptionApplication)DGViewData.SelectedItem; if (adoptionApplication != null) { this.customerEmail = adoptionApplication.CustomerEmail; reviewerManager = new ReviewerManager(); customer = reviewerManager.retrieveCustomerByCustomerName(this.customerEmail); List <CustomerQuestionnar> customerQuestionnars = reviewerManager.retrieveCustomerQuestionnar(this.customerEmail); lblCustomerName.Content = adoptionApplication.CustomerEmail; DGViewQuestionnair.ItemsSource = customerQuestionnars; adoptionApplication = new AdoptionApplication(); ReviewerDecission.Visibility = Visibility.Hidden; ViewAdoptionApplications.Visibility = Visibility.Hidden; CustomerQustionnair.Visibility = Visibility.Visible; } else { lblAdoptionApplicationErrorMessage.Content = "Please select a customer"; } } catch (Exception) { lblAdoptionApplicationErrorMessage.Content = "This customer did not fill the questionnar!"; } }
public void TestAdoptionCustomerAddAdoptionCustomer() { // arrange IAdoptionCustomerManager adoptionCustomerManager = new AdoptionCustomerManager(_adoptionCustomerAccessor); var customer = new AdoptionCustomer { CustomerEmail = "*****@*****.**", FirstName = "Fake", LastName = "Fake", PhoneNumber = "1110002222", AddressLineOne = "Fake", AddressLineTwo = "Fake", City = "Fake", State = "Fake", Zipcode = "Fake", Active = true }; // act int rows = _adoptionCustomerAccessor.InsertAdoptionCustomer(customer); // assert Assert.AreEqual(1, rows); }
public void TestGetCustomerByCustomerName() { //arrange AdoptionCustomer customer = null; string customerName = "Elamin"; //acct customer = reviewerManager.retrieveCustomerByCustomerName(customerName); //assert Assert.AreEqual(customerName, customer.LastName); }
/// <summary> /// NAME: Austin Gee /// DATE: 4/28/2020 /// CHECKED BY: /// /// Adds a customer to the database /// </summary> /// <remarks> /// UPDATED BY: NA /// UPDATE DATE: NA /// WHAT WAS CHANGED: NA /// /// </remarks> /// <param name="customer"></param> /// <returns></returns> public bool AddAdoptionCustomer(AdoptionCustomer customer) { try { return(1 == _adoptionCustomerAccessor.InsertAdoptionCustomer(customer)); } catch (Exception ex) { throw new ApplicationException("Database Error", ex); } }
/// <summary> /// Creator: Awaab Elamin /// Created: 2020/15/02 /// Approver: Mohamed Elamin /// select the customer record from the customer list /// </summary> /// <remarks> /// Updater: /// Updated: /// Update: /// </remarks> /// <param name="customerLastName"></param> /// <returns>ReturnCustomer</returns> public AdoptionCustomer getCustomerByCustomerName(string customerLastName) { AdoptionCustomer ReturnCustomer = new AdoptionCustomer(); foreach (AdoptionCustomer customer in customers) { if (customer.LastName == customerLastName) { ReturnCustomer = customer; break; } } return(ReturnCustomer); }
/// <summary> /// Creator: Awaab Elamin /// Created: 2020/02/04 /// Approver: Mohamed Elamin /// Retrieve Customer record from customer table by his last name. /// </summary> /// <remarks> /// Updater: Mohamed Elamin /// Updated: 2020/04/21 /// Update: Fixed comments format. /// </remarks> /// <param name="customerLastName"></param> /// <returns>ourCustomer</returns> public AdoptionCustomer getCustomerByCustomerName(string customerLastName) { AdoptionCustomer ourCustomer = new AdoptionCustomer(); //List<AdoptionCustomer> customers = new List<AdoptionCustomer>(); //var conn = DBConnection.GetConnection(); //string cmdText = @"sp_select_all_active_users"; //var cmd = new SqlCommand(cmdText, conn); //cmd.CommandType = CommandType.StoredProcedure; //try //{ // conn.Open(); // SqlDataReader reader = cmd.ExecuteReader(); // if (reader.HasRows) // { // while (reader.Read()) // { // AdoptionCustomer activeCustomer = new AdoptionCustomer(); // activeCustomer.CustomerID = reader.GetInt32(0); // activeCustomer.FirstName = reader.GetString(1); // activeCustomer.LastName = reader.GetString(2); // activeCustomer.PhoneNumber = reader.GetString(3); // activeCustomer.Email = reader.GetString(4); // activeCustomer.Active = true; // customers.Add(activeCustomer); // } // reader.Close(); // } // foreach (AdoptionCustomer customer in customers) // { // if (customer.LastName == customerLastName) // { // int customerID = getCustomerID(customer.CustomerID); // ourCustomer = customer; // ourCustomer.CustomerID = customerID; // } // } //} //catch (Exception) //{ // throw; //} //finally //{ // conn.Close(); //} return(ourCustomer); }
public int InsertAdoptionCustomer(AdoptionCustomer customer) { int rows = 0; try { adoptionCustomers.Add(customer); rows += 1; } catch (Exception) { throw; } return(rows); }
public ActionResult AdoptionCustomerRegister(FormCollection formCollection) { int animalID = Int32.Parse(formCollection[1]); string email = formCollection[2]; string firstName = formCollection[3]; string lastName = formCollection[4]; string phoneNumber = formCollection[5]; string address1 = formCollection[6]; string address2 = formCollection[7]; string city = formCollection[8]; string state = formCollection[9]; string zip = formCollection[10]; try { var customer = new AdoptionCustomer { CustomerEmail = email, FirstName = firstName, LastName = lastName, PhoneNumber = phoneNumber, AddressLineOne = address1, AddressLineTwo = address2, City = city, State = state, Zipcode = zip }; _adoptionCustomerManager.AddAdoptionCustomer(customer); return(RedirectToAction("CustomerConfirmAdoptionApplication", new { animalID = animalID })); } catch (Exception ex) { throw ex; } return(View()); }
public ActionResult RegisterAcceptance(FormCollection formCollection) { string email = formCollection[1]; string firstName = formCollection[2]; string lastName = formCollection[3]; string phoneNumber = formCollection[4]; string address1 = formCollection[5]; string address2 = formCollection[6]; string city = formCollection[7]; string state = formCollection[8]; string zip = formCollection[9]; try { var customer = new AdoptionCustomer { CustomerEmail = email, FirstName = firstName, LastName = lastName, PhoneNumber = phoneNumber, AddressLineOne = address1, AddressLineTwo = address2, City = city, State = state, Zipcode = zip }; _customerManager.AddAdoptionCustomer(customer); return(RedirectToAction("Index", "Home")); } catch (Exception ex) { throw ex; } return(View()); }
/// <summary> /// Creator: Awaab Elamin /// Created: 2020/02/04 /// Approver: Mohamed Elamin /// Default Constructor intial adotionAccessor to /// reviewer manager accessor and customer object /// </summary /// <remarks> /// Updater: Mohamed Elamin /// Updated: 2020/04/21 /// Update: Fixed comments format /// </remarks> public ReviewerManager() { adoptionAccessor = new ReviewerAccessor(); customer = null; }
/// <summary> /// Creator: Awaab Elamin /// Created: 2020/02/04 /// Approver: Mohamed Elamin /// Retrieve a customer record by his last name /// </summary> /// <remarks> /// Updater: Mohamed Elamin /// Updated: 2020/04/21 /// Update: Fixed comments format.Added try catch block. /// </remarks> /// <param name="customerLastName"></param> /// <returns>customer</returns> public AdoptionCustomer retrieveCustomerByCustomerName(string customerLastName) { customer = adoptionAccessor.getCustomerByCustomerName(customerLastName); return(customer); }