Ejemplo n.º 1
0
        private void EditACustomer()
        {
            Console.WriteLine("What is the customers ID?");
            int customerID = int.Parse(Console.ReadLine());

            Console.WriteLine("What number value would you like to change?\n" +
                              "1: First Name\n" +
                              "2: Last Name\n" +
                              "3: Customer Type");
            string customerChange = (Console.ReadLine());

            switch (customerChange)
            {
            case "1":
                Console.WriteLine("What is the new first name?");
                string firstName = Console.ReadLine();
                foreach (Crud crud in _customerRepo.GetAllCustomerInfo())
                {
                    if (crud.CustomerID == customerID)
                    {
                        crud.FirstName = firstName;
                    }
                }
                //change first name
                break;

            case "2":
                Console.WriteLine("What is the new last name?");
                string lastName = Console.ReadLine();
                foreach (Crud crud in _customerRepo.GetAllCustomerInfo())
                {
                    if (crud.CustomerID == customerID)
                    {
                        crud.LastName = lastName;
                    }
                }
                // change last name
                break;

            case "3":
                Console.WriteLine("What is the new customer type?\n" +
                                  "1: Potential\n" +
                                  "2: Current\n" +
                                  "3: Past");
                int          cType        = int.Parse(Console.ReadLine());
                CustomerType customerType = (CustomerType)cType;
                foreach (Crud crud in _customerRepo.GetAllCustomerInfo())
                {
                    if (crud.CustomerID == customerID)
                    {
                        crud.CustomerType = customerType;
                    }
                }
                // change customer type
                break;
            }
        }
Ejemplo n.º 2
0
        public void AddAndGetMethod()
        {
            Crud_Repository repoInfo      = new Crud_Repository();
            Crud            customerInfo  = new Crud(1, "John", "Walters", CustomerType.Current);
            Crud            customerInfo2 = new Crud(2, "Jan", "Fittz", CustomerType.Current);

            repoInfo.AddCustomerToEmailList(customerInfo);
            repoInfo.AddCustomerToEmailList(customerInfo2);
            List <Crud> list = repoInfo.GetAllCustomerInfo();

            var expected = 2;
            var actual   = list.Count;

            Assert.AreEqual(expected, actual);
        }