/// <summary> /// Method to populateCustomers list /// </summary> private void populateCustomers() { try { string provinceFilter = Console.ReadLine(); int selection; bool isNumber = int.TryParse(provinceFilter, out selection); customers = CustomertRepository.GetCustomers(selection); if (customers != null && customers.Count() > NULL_CUSTOMERS) { if (selection > 0 && selection <= provinces.Count) { ConsolePrinter.Print(customers, selection); } else { Console.WriteLine("Error please pick a number between 1 to {0}", provinces.Count); } } else { Console.WriteLine("No customers to print"); } } catch (SqlException ex) { Console.WriteLine("Data Access Error\n\n{0}", ex.Message); } catch (Exception ex) { Console.WriteLine("Processing Error\n\n{0}", ex.Message); } }
/// <summary> /// Method to return a list of Provinces from the CustomerRepository /// </summary> /// <param name="index">the index to set</param> /// <returns>the provinces</returns> public string Provinces(int index) { CustomertRepository province = new CustomertRepository(); string provinces = province.GetProvinces().ElementAt(index - ELEMENT); return(provinces); }
/// <summary> /// Method to populateCustomers list through populateSelectionList method /// </summary> private void populateCustomers() { int selection = SELECTION_START; do { try { populateSelectionList(); string provinceFilter = Console.ReadLine(); bool isNumber = int.TryParse(provinceFilter, out selection); customers = CustomertRepository.GetCustomers(selection); if (selection > 0 && selection <= provinces.Count - ELEMENT) { if (customers != null && customers.Count() > NULL_CUSTOMERS) { ConsolePrinter.Print(customers, selection); } else { Console.WriteLine("No customers to print"); Environment.Exit(EXIT_CODE); } } else if (selection == provinces.Count) { Console.WriteLine("COMP2614Assign04 will now exit . . ."); Environment.Exit(EXIT_CODE); } } catch (SqlException ex) { Console.WriteLine("Data Access Error\n\n{0}", ex.Message); } catch (Exception) { Console.WriteLine("**********INVALID SELECTION**********\nPlease select a number between 1 to {0}\n\n", provinces.Count); } } while (selection >= SELECTION_START); }