Exemplo n.º 1
0
        private void RemoveCustomer()
        {
            List <Customer> customerList = _customerRepo.GetCustomerList();

            Console.WriteLine("Here is the current list of all customers in the database.");
            DisplayList();

            Console.WriteLine("Please enter the first name of the customer you would like to remove");
            string firstNameInput = Console.ReadLine();

            Console.WriteLine("Now, please enter their last name");
            string lastNameInput = Console.ReadLine();

            foreach (Customer customer in customerList)
            {
                if (firstNameInput == customer.FirstName && lastNameInput == customer.LastName)
                {
                    _customerRepo.RemoveCustomer(customer);
                    break;
                }
            }
            Console.WriteLine($"Customer {firstNameInput} {lastNameInput} has been removed from the list.");

            Console.Clear();
        }
Exemplo n.º 2
0
        public void ViewMailingList()
        {
            Console.Clear();
            List <Customer> customerList = _customerRepo.GetCustomerList();

            Console.WriteLine("First Name\tLast Name\tType\t\tEmail");
            var orderedList = customerList.OrderBy(c => c.LastName).ToList();

            foreach (Customer customer in orderedList)
            {
                Console.WriteLine($"{customer.FirstName}\t\t{customer.LastName}\t\t{(CustomerType)customer.CustomerType}\t\t{customer.Email}");
            }
            Console.ReadLine();
        }
Exemplo n.º 3
0
        private void ReadCustomer()
        {
            List <Customer> customerList = _customerRepo.GetCustomerList();
            int             result       = SearchDatabase();

            if (result == -1)
            {
                Console.WriteLine("No customer found with this last name.");
            }
            else
            {
                Console.WriteLine($"First name: {customerList[result].FirstName}" +
                                  $"\nLast name: {customerList[result].LastName}" +
                                  $"\nType: {customerList[result].Type}" +
                                  $"\nEmail: {customerList[result].Email}");
            }
        }
Exemplo n.º 4
0
        List <CustomerInfo> _customers;                                  //declared the list herr
        public void Run()
        {
            _customers = _customerInfoRepo.GetCustomerList(); //now we have access to the list, so define it
            bool isRunning = true;

            while (isRunning)
            {
                Console.WriteLine("Greetings, Skillet" +
                                  "\n1. Create a Customer " +
                                  "\n2. See Individual Customer" +
                                  "\n3. Delete Customer " +
                                  "\n4. Update Customer " +
                                  "\n5. Show List of All Customers " +
                                  "\n6. Exit this hizzle");

                int input = int.Parse(Console.ReadLine());

                switch (input)
                {
                case 1:
                    CreateCustomer();
                    break;

                case 2:
                    PrintIndividualCustomer();
                    break;

                case 3:
                    DeleteCustomer();
                    break;

                case 4:
                    UpdateCustomer();
                    break;

                case 5:
                    ShowAllCustomerList();
                    break;
                }
            }
        }
Exemplo n.º 5
0
        //This challenge is not at all finished
        static void Main(string[] args)
        {
            CustomerRepository customerRepo = new CustomerRepository();
            List <Customer>    customerList = customerRepo.GetCustomerList();

            Customer newCustomer = new Customer();
            Customer jim         = new Customer("Jim", "Halpert", CustomerType.Current);
            Customer dwight      = new Customer("Dwight", "Shrute", CustomerType.Potential);

            customerRepo.AddCustomerToList(jim);
            customerRepo.AddCustomerToList(dwight);

            int menuResponse = 0;

            while (menuResponse != 5)
            {
                //Sorts customerList alphabettically by last name.
                customerList.Sort(delegate(Customer customer1, Customer customer2) { return(customer1.LastName.CompareTo(customer2.LastName)); });

                Console.WriteLine($"Welcome to Komodo Insurance Customer Log!\n\nWhat would you like to do?\n\t1.See list of customers\n\t2.Add new customer\n\t3.Update current customer\n\t4.Delete current customer\n\t5.Exit program");
                menuResponse = int.Parse(Console.ReadLine());

                switch (menuResponse)
                {
                case 1:
                    Console.WriteLine($"Here are all current customers:\nLast Name\tFirst Name\tCustomer Status\t\tSuggested Email");
                    foreach (Customer customer in customerList)
                    {
                        string email = "";
                        if (customer.CustomerType == CustomerType.Current)
                        {
                            email = "Thank you for your work with us. We appreciate your loyalty. Here's a coupon.";
                        }
                        if (customer.CustomerType == CustomerType.Past)
                        {
                            email = "It's been a long time since we've heard from you, we want you back!";
                        }
                        else
                        {
                            email = " We currently have the lowest rates on Helicopter Insurance!";
                        }

                        Console.WriteLine($"{customer.LastName}\t\t{customer.FirstName}\t\t{customer.CustomerType}\t\t{email}");
                    }
                    Console.ReadLine();
                    break;

                case 2:
                    Console.WriteLine($"Great! Let's add new customer info!\n\nPlease enter their first name:");
                    newCustomer.FirstName = Console.ReadLine();

                    Console.WriteLine("Please enter their last name: ");
                    newCustomer.LastName = Console.ReadLine();

                    Console.WriteLine("Please input customer status: Potential, Current, or Past");
                    var customerType = Console.ReadLine();
                    newCustomer.CustomerType = (CustomerType)Enum.Parse(typeof(CustomerType), customerType);
                    customerRepo.AddCustomerToList(newCustomer);
                    break;

                case 3:
                    Console.WriteLine("Who would you like to update?");
                    var updateResponse = Console.ReadLine();
                    Console.WriteLine($"Would you like to:\n\t1. Change first name\n\t2.Change last name\n\t3.Change customer status");
                    var updateType = Console.ReadLine();
                    if (updateType == "1")
                    {
                        break;
                    }

                case 4:
                    //Only removes added customers. Not ones that are hard coded in.
                    Console.WriteLine($"Which customer would you like to remove?\n Enter First Name:");
                    var removeResponse = Console.ReadLine();
                    Console.WriteLine("Enter Last Name:");
                    var removeLast = Console.ReadLine();
                    if (newCustomer.FirstName == removeResponse && newCustomer.LastName == removeLast)
                    {
                        customerList.Remove(newCustomer);
                    }
                    break;

                default:
                    menuResponse = 5;
                    break;
                }
            }
        }
Exemplo n.º 6
0
        public void Run()
        {
            CustomerRepository customerRepo = new CustomerRepository();
            Customer           customer     = new Customer();
            List <Customer>    customers    = customerRepo.GetCustomerList();
            bool           response         = true;
            CustomerStatus status;

            while (response)
            {
                Console.WriteLine("Welcome to Komodo Customer management!\n\nWhat would you like to do?\n\t" +
                                  "1. See all customers\n\t" +
                                  "2. Add customer\n\t" +
                                  "3. Remove customer\n\t" +
                                  "4. Update customer status\n\t" +
                                  "5. Exit");
                var menuInput = int.Parse(Console.ReadLine());
                switch (menuInput)
                {
                case 1:
                    List <Customer> sortedList = customers.OrderBy(c => c.Name).ToList();
                    Console.WriteLine("Name\t\tStatus\t\tEmail");
                    if (customers.Count < 1 || customers.Capacity == 0)
                    {
                        Console.WriteLine("It appears there aren't any customers.");
                    }
                    else
                    {
                        foreach (Customer c in sortedList)
                        {
                            Console.WriteLine($"{c.Name}\t\t{c.Status}\t\t{c.EmailResponse}");
                        }
                    }
                    Console.ReadLine();
                    break;

                case 2:
                    Console.Write("Enter customer name: ");
                    string name = Console.ReadLine();
                    Console.Write("Enter customer status (Current, Past, Potential): ");
                    string statusInput = Console.ReadLine().ToLower();
                    status   = customerRepo.GetCustomerStatus(statusInput);
                    customer = new Customer()
                    {
                        Name          = name,
                        Status        = status,
                        EmailResponse = customerRepo.GetEmailResponse(status),
                    };
                    customerRepo.AddCustomerToList(customer);
                    break;

                case 3:
                    Console.WriteLine("Enter the name of the customer you would like to remove: \n\n" +
                                      "Name\t\tStatus");
                    if (customers.Count < 1 || customers.Capacity == 0)
                    {
                        Console.WriteLine("It appears there aren't any customers.");
                    }
                    else
                    {
                        foreach (Customer c in customers)
                        {
                            Console.WriteLine($"{c.Name}\t\t{c.Status}");
                        }

                        var remove = Console.ReadLine();
                        customerRepo.RemoveCustomerFromList(remove);
                    }
                    break;

                case 4:
                    Console.WriteLine("Enter the name of the customer you would like to update:");
                    PrintCustomerDetails(customers);
                    var updateName = Console.ReadLine();
                    foreach (Customer c in customers)
                    {
                        if (c.Name == updateName)
                        {
                            Console.WriteLine($"Current Name: {c.Name}. Would you like to update?");
                            if (customerRepo.YesNoResponse(Console.ReadLine()))
                            {
                                Console.Write("Enter new name: ");
                                c.Name = Console.ReadLine();
                            }
                            Console.WriteLine($"Current Status: {c.Status}. Would you like to update?");
                            if (customerRepo.YesNoResponse(Console.ReadLine()))
                            {
                                Console.Write("Enter new status: ");
                                string updateStatus = Console.ReadLine().ToLower();
                                c.Status = customerRepo.GetCustomerStatus(updateStatus);
                            }
                        }
                    }
                    break;

                default:
                    response = false;
                    break;
                }
            }
        }