Пример #1
0
        private void UpdateCustomer()
        {
            Console.WriteLine("Enter the first name of the customer you would like to edit:");
            string first = Console.ReadLine();

            Console.WriteLine("Enter the last name of the customer you would like to edit:");
            string last = Console.ReadLine();

            // reusing KeyIsDelete to ensure customer key exists
            if (!customerList.KeyIsUnique(last + first))
            {
                Console.WriteLine("Enter the new first name of this customer:");
                string newFirst = Console.ReadLine();
                Console.WriteLine("Enter the new last name of this customer:");
                string newLast = Console.ReadLine();
                Customer.CustomerType newCustType = InputEventTypeHelper("\nEnter the type of customer this is:");
                if (newCustType != Customer.CustomerType.Invalid)
                {
                    Customer newCustomer = new Customer(newFirst, newLast, newCustType);
                    if (customerList.UpdateCustomer(first, last, newCustomer))
                    {
                        Console.WriteLine("Customer Updated.");
                    }
                    else
                    {
                        Console.WriteLine("Customer not updated. New customer name must be unique.");
                    }
                }
            }
            else
            {
                Console.WriteLine("Customer not found.");
            }
        }
Пример #2
0
        public void AddCustomer()
        {
            Console.WriteLine("Enter the new customers first name:");
            string first = Console.ReadLine();

            Console.WriteLine("Enter the new customers last name:");
            string last = Console.ReadLine();

            Customer.CustomerType newCustType = InputEventTypeHelper("\nEnter the type of customer this is:");
            // test cutomertype and addcustomer. if both true, customer was added
            if (newCustType != Customer.CustomerType.Invalid && customerList.AddCustomer(first, last, newCustType))
            {
                Console.WriteLine("\nCustomer added.");
            }
            else
            {
                Console.WriteLine("\nCustomer not added.");
            }
        }
Пример #3
0
        public bool AddCustomer(string first, string last, Customer.CustomerType type)
        {
            Customer customerToAdd   = new Customer(last, first, type);
            int      listCountBefore = _listOfCustomers.Count;

            //+++++++++++++++++++++++++++
            // add test for key uniqueness
            if (KeyIsUnique(last + first))
            {
                _listOfCustomers.Add(last + first, customerToAdd);
                if (listCountBefore < _listOfCustomers.Count)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }