private void SeedCustomers()
        {
            PotentialCustomer customer1 = new PotentialCustomer("Bob", "Smith");

            _customerRepo.AddCustomer(customer1);

            PotentialCustomer customer2 = new PotentialCustomer("Jeremy", "Adams");

            _customerRepo.AddCustomer(customer2);

            CurrentCustomer customer3 = new CurrentCustomer("Selina", "McCoy");

            _customerRepo.AddCustomer(customer3);

            CurrentCustomer customer4 = new CurrentCustomer("Emily", "Arnold");

            _customerRepo.AddCustomer(customer4);

            PastCustomer customer5 = new PastCustomer("Jim", "Williams");

            _customerRepo.AddCustomer(customer5);

            PastCustomer customer6 = new PastCustomer("Henry", "Jones");

            _customerRepo.AddCustomer(customer6);
        }
        public void Arrange()
        {
            PastCustomer customer1 = new PastCustomer("Lina", "Smith");

            _repo.AddCustomer(customer1);

            PotentialCustomer customer2 = new PotentialCustomer("Kel", "Smith");

            _repo.AddCustomer(customer2);

            CurrentCustomer customer3 = new CurrentCustomer("Eric", "Smith");

            _repo.AddCustomer(customer3);

            PastCustomer customer4 = new PastCustomer("Chris", "Forsythe");

            _repo.AddCustomer(customer4);

            CurrentCustomer customer5 = new CurrentCustomer("Jacob", "Bullock");

            _repo.AddCustomer(customer5);

            PotentialCustomer customer6 = new PotentialCustomer("Kate", "Harrison");

            _repo.AddCustomer(customer6);
        }
Esempio n. 3
0
        public void AddPast()
        {
            PastCustomer customer = new PastCustomer();

            Console.WriteLine("Enter past customer ID:");
            if (Int32.TryParse(Console.ReadLine(), out _userInput))
            {
                if (_customerRepo.GetCustomerById(_userInput) == null)
                {
                    customer.Id = _userInput;
                }
                else
                {
                    Console.WriteLine("This customer ID is already in use.\n" +
                                      "Press any key to try again with a different ID.");
                    Console.ReadKey();
                }
            }
            else
            {
                Console.WriteLine("Please enter a valid customer ID.\n" +
                                  "Press any key to try again.");
                Console.ReadKey();
            }
            Console.WriteLine("Enter past customer first name:");
            customer.FirstName = Console.ReadLine();
            Console.WriteLine("Enter past customer last name:");
            customer.LastName = Console.ReadLine();
            Console.WriteLine("Enter past customer email");
            customer.Email = Console.ReadLine();
            Console.Clear();
            _customerRepo.AddCustomerToList(customer);
        }
        public void AddCustomer_ShouldReturnTrue()
        {
            //Arrange
            PastCustomer       pastCustomer = new PastCustomer("Bob", "Smith");
            CustomerRepository repo         = new CustomerRepository();

            //Act
            bool wasAdded = repo.AddCustomer(pastCustomer);

            //Assert
            Assert.IsTrue(wasAdded);
        }
Esempio n. 5
0
        public void SeedContent()
        {
            CurrentCustomer customerOne = new CurrentCustomer(1, "Konrad", "Haight", "*****@*****.**");

            _customerRepo.AddCustomerToList(customerOne);
            PastCustomer customerTwo = new PastCustomer(2, "Nicole", "Haight", "*****@*****.**");

            _customerRepo.AddCustomerToList(customerTwo);
            PotentialCustomer customerThree = new PotentialCustomer(3, "Ruby", "Haight", "none");

            _customerRepo.AddCustomerToList(customerThree);
        }
Esempio n. 6
0
        public void EditCustomer()
        {
            Console.WriteLine("Enter the customer ID:");
            if (Int32.TryParse(Console.ReadLine(), out _userInput))
            {
                if (_customerRepo.GetCustomerById(_userInput) != null)
                {
                    ICustomer oldCustomer = _customerRepo.GetCustomerById(_userInput);
                    ICustomer newCustomer;

                    if (oldCustomer is CurrentCustomer)
                    {
                        newCustomer = new CurrentCustomer();
                    }
                    else if (oldCustomer is PastCustomer)
                    {
                        newCustomer = new PastCustomer();
                    }
                    else
                    {
                        newCustomer = new PotentialCustomer();
                    }

                    Console.WriteLine("Enter the new customer ID");
                    newCustomer.Id = Int32.Parse(Console.ReadLine());
                    Console.WriteLine("Enter the new customer first name");
                    newCustomer.FirstName = Console.ReadLine();
                    Console.WriteLine("Enter the new customer last name");
                    newCustomer.LastName = Console.ReadLine();
                    Console.WriteLine("Enter the new customer email");
                    newCustomer.Email = Console.ReadLine();

                    _customerRepo.UpdateExistingCustomer(_userInput, newCustomer);
                    Console.Clear();
                }
                else
                {
                    Console.WriteLine("Failed to locate customer\n" +
                                      "Press any key to try again.");
                    Console.ReadKey();
                    Console.Clear();
                }
            }
            else
            {
                Console.WriteLine("Please enter a valid customer ID\n" +
                                  "Press any key to try again.");
                Console.ReadKey();
                Console.Clear();
            }
        }
        private void AddNewPastCustomer()
        {
            Console.Clear();

            string       firstName = _prompt.PromptUserForFirstName();
            string       lastName  = _prompt.PromptUserForLastName();
            PastCustomer customer  = new PastCustomer(firstName, lastName);

            _customerRepo.AddCustomer(customer);

            Console.Clear();
            Console.WriteLine("Customer was successfully added...");
            Console.ReadLine();
        }
Esempio n. 8
0
 public void AddPastCustomerToList(PastCustomer customer)
 {
     _pastCustomerList.Add(customer);
 }
        private void UpdateACustomer()
        {
            Console.Clear();

            Console.WriteLine("Which customer would you like to update?");
            string firstName = _prompt.PromptUserForFirstName();
            string lastName  = _prompt.PromptUserForLastName();

            Customer customer = _customerRepo.GetCustomerByName(firstName, lastName);

            bool isUserResponseYesToQuestionUpdateName = _prompt.PromptUserYesOrNo("Update a Customer's Name? (Y/N)");

            if (isUserResponseYesToQuestionUpdateName)
            {
                Console.Clear();

                Console.WriteLine("Please Enter New Name:");

                string newFirstName = _prompt.PromptUserForFirstName();
                string newLastName  = _prompt.PromptUserForLastName();

                _customerRepo.UpdateCustomerFirstName(customer, newFirstName);
                _customerRepo.UpdateCustomerLastName(customer, newLastName);

                Console.Clear();
                Console.WriteLine($"Customer {firstName} {lastName} was successfully updated to {customer.FullName}.");

                bool isUserResponseYesToQuestionUpdateType = _prompt.PromptUserYesOrNo("Update a Customer's Type? Y/N");
                if (isUserResponseYesToQuestionUpdateType)
                {
                    if (customer is PotentialCustomer)
                    {
                        Console.WriteLine($"Customer is a Potential Customer");
                        bool isUserResponseYesToConvertQuestion = _prompt.PromptUserYesOrNo("Convert Potential Customer to Current Customer? Y/N");
                        if (isUserResponseYesToConvertQuestion)
                        {
                            Console.Clear();

                            CurrentCustomer current = (CurrentCustomer)(customer as PotentialCustomer);
                            _customerRepo.RemoveCustomer(customer);
                            _customerRepo.AddCustomer(current);

                            Console.WriteLine("Customer has been successfully updated...");
                            Console.WriteLine("Press enter to return to main menu...");
                            Console.ReadLine();
                        }
                        else
                        {
                            Console.WriteLine("Press enter to return to main menu...");
                            Console.ReadLine();
                        }
                    }
                    else if (customer is PastCustomer)
                    {
                        Console.WriteLine($"Customer is a Past Customer");
                        bool isUserResponseYesToConvertQuestion = _prompt.PromptUserYesOrNo("Convert Past Customer to Current Customer? Y/N");
                        if (isUserResponseYesToConvertQuestion)
                        {
                            Console.Clear();

                            CurrentCustomer current = (CurrentCustomer)(customer as PastCustomer);
                            _customerRepo.RemoveCustomer(customer);
                            _customerRepo.AddCustomer(current);

                            Console.WriteLine("Customer has been successfully updated...");
                            Console.WriteLine("Press enter to return to main menu...");
                            Console.ReadLine();
                        }
                        else
                        {
                            Console.WriteLine("Press enter to return to main menu...");
                            Console.ReadLine();
                        }
                    }
                    else if (customer is CurrentCustomer)
                    {
                        Console.WriteLine($"Customer is a Current Customer");
                        bool isUserResponseYesToConvertQuestion = _prompt.PromptUserYesOrNo("Convert Current Customer to Past Customer? Y/N");
                        if (isUserResponseYesToConvertQuestion)
                        {
                            Console.Clear();

                            PastCustomer past = (PastCustomer)(customer as CurrentCustomer);
                            _customerRepo.RemoveCustomer(customer);
                            _customerRepo.AddCustomer(past);

                            Console.WriteLine("Customer has been successfully updated...");
                            Console.WriteLine("Press enter to return to main menu...");
                            Console.ReadLine();
                        }
                        else
                        {
                            Console.WriteLine("Press enter to return to main menu...");
                            Console.ReadLine();
                        }
                    }
                    else
                    {
                        Console.WriteLine("Press enter to return to main menu...");
                        Console.ReadLine();
                    }
                }
                else
                {
                    Console.WriteLine("Press enter to return to main menu...");
                    Console.ReadLine();
                }
            }
            else
            {
                bool isUserResponseYesToQuestionUpdateType = _prompt.PromptUserYesOrNo("Update a Customer's Type? Y/N");
                if (isUserResponseYesToQuestionUpdateType)
                {
                    if (customer is PotentialCustomer)
                    {
                        Console.WriteLine($"Customer is a Potential Customer");
                        bool isUserResponseYesToConvertQuestion = _prompt.PromptUserYesOrNo("Convert Potential Customer to Current Customer? Y/N");
                        if (isUserResponseYesToConvertQuestion)
                        {
                            Console.Clear();

                            CurrentCustomer current = (CurrentCustomer)(customer as PotentialCustomer);
                            _customerRepo.RemoveCustomer(customer);
                            _customerRepo.AddCustomer(current);

                            Console.WriteLine("Customer has been successfully updated...");
                            Console.WriteLine("Press enter to return to main menu...");
                            Console.ReadLine();
                        }
                        else
                        {
                            Console.WriteLine("Press enter to return to main menu...");
                            Console.ReadLine();
                        }
                    }
                    else if (customer is PastCustomer)
                    {
                        Console.WriteLine($"Customer is a Past Customer");
                        bool isUserResponseYesToConvertQuestion = _prompt.PromptUserYesOrNo("Convert Past Customer to Current Customer? Y/N");
                        if (isUserResponseYesToConvertQuestion)
                        {
                            Console.Clear();

                            CurrentCustomer current = (CurrentCustomer)(customer as PastCustomer);
                            _customerRepo.RemoveCustomer(customer);
                            _customerRepo.AddCustomer(current);

                            Console.WriteLine("Customer has been successfully updated...");
                            Console.WriteLine("Press enter to return to main menu...");
                            Console.ReadLine();
                        }
                        else
                        {
                            Console.WriteLine("Press enter to return to main menu...");
                            Console.ReadLine();
                        }
                    }
                    else if (customer is CurrentCustomer)
                    {
                        Console.WriteLine($"Customer is a Current Customer");
                        bool isUserResponseYesToConvertQuestion = _prompt.PromptUserYesOrNo("Convert Current Customer to Past Customer? Y/N");
                        if (isUserResponseYesToConvertQuestion)
                        {
                            Console.Clear();

                            PastCustomer past = (PastCustomer)(customer as CurrentCustomer);
                            _customerRepo.RemoveCustomer(customer);
                            _customerRepo.AddCustomer(past);

                            Console.WriteLine("Customer has been successfully updated...");
                            Console.WriteLine("Press enter to return to main menu...");
                            Console.ReadLine();
                        }
                        else
                        {
                            Console.WriteLine("Press enter to return to main menu...");
                            Console.ReadLine();
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Press enter to return to main menu...");
                    Console.ReadLine();
                }
            }
        }