Ejemplo n.º 1
0
            private void UpdateExistingCustomer()
            {
                ShowCustomers();
                Console.WriteLine("Enter the ID for the customer you would like to change.");
                string   idToChange       = Console.ReadLine();
                C5Emails customerToChange = repo.GetCustomerByID(idToChange);

                Console.WriteLine("Enter the number of the customer type:\n" +
                                  "1. Current\n" +
                                  "2. Past\n" +
                                  "3. Potential\n");
                string input       = Console.ReadLine();
                bool   stopRunning = false;

                while (!stopRunning)
                {
                    switch (input)
                    {
                    case "1":
                        customerToChange.CustomerType = CustomerType.Current;
                        stopRunning = true;
                        break;

                    case "2":
                        customerToChange.CustomerType = CustomerType.Past;
                        stopRunning = true;
                        break;

                    case "3":
                        customerToChange.CustomerType = CustomerType.Potential;
                        stopRunning = true;
                        break;

                    default:
                        Console.WriteLine("Please enter a valid input.");
                        stopRunning = false;
                        break;
                    }
                }
                Console.WriteLine("Please enter the customer's ID.");
                customerToChange.ID = Console.ReadLine();
                Console.WriteLine("Please enter the customer's first name.");
                customerToChange.FirstName = Console.ReadLine();
                Console.WriteLine("Please enter the customer's last name.");
                customerToChange.LastName = Console.ReadLine();
                bool wasChanged = repo.AddToList(customerToChange);;

                if (wasChanged)
                {
                    Console.WriteLine("This content was successfully changed.");
                }
                else
                {
                    Console.WriteLine("Content could not be changed");
                }
            }
Ejemplo n.º 2
0
            private void AddNewCustomer()
            {
                C5Emails newcustomer = new C5Emails();

                Console.Clear();
                Console.WriteLine("Enter the number of the customer type you would like to add:\n" +
                                  "1. Current\n" +
                                  "2. Past\n" +
                                  "3. Potential\n");
                string input       = Console.ReadLine();
                bool   stopRunning = false;

                while (!stopRunning)
                {
                    switch (input)
                    {
                    case "1":
                        newcustomer.CustomerType = CustomerType.Current;
                        stopRunning = true;
                        break;

                    case "2":
                        newcustomer.CustomerType = CustomerType.Past;
                        stopRunning = true;
                        break;

                    case "3":
                        newcustomer.CustomerType = CustomerType.Potential;
                        stopRunning = true;
                        break;

                    default:
                        Console.WriteLine("Please enter a valid input.");
                        stopRunning = false;
                        break;
                    }
                }
                Console.WriteLine("Please enter the customer's ID.");
                newcustomer.ID = Console.ReadLine();
                Console.WriteLine("Please enter the customer's first name.");
                newcustomer.FirstName = Console.ReadLine();
                Console.WriteLine("Please enter the customer's last name.");
                newcustomer.LastName = Console.ReadLine();

                bool wasAdded = repo.AddToList(newcustomer);

                if (wasAdded == true)
                {
                    Console.WriteLine("Your content was succesfully added.");
                }
                else
                {
                    Console.WriteLine("Oops something went wrong. Your content was not added.");
                }
            }
Ejemplo n.º 3
0
        public void AddToDirectory_ShouldGetCorrectBoolean()
        {
            //Arrange
            C5Emails content    = new C5Emails();
            C5_Repo  repository = new C5_Repo();

            //Act
            bool addResult = repository.AddToList(content);

            //Assert
            Assert.IsTrue(addResult);
        }
Ejemplo n.º 4
0
        public void GetByTitle_ShouldReturnCorrectContent()
        {
            //Arrange
            C5_Repo  repo       = new C5_Repo();
            C5Emails newContent = new C5Emails("Jim", "Istired", "verytired", CustomerType.Past);

            repo.AddToList(newContent);
            string id = "Jim";

            //Act
            C5Emails searchResult = repo.GetCustomerByID(id);

            //Assert
            Assert.AreEqual(searchResult.ID, id);
        }
Ejemplo n.º 5
0
        public void DeleteExistingContent_ShouldReturnTrue()
        {
            //Arrange
            C5_Repo  repo    = new C5_Repo();
            C5Emails content = new C5Emails("Jim", "Istired", "verytired", CustomerType.Past);

            repo.AddToList(content);

            //Act
            C5Emails oldContent = repo.GetCustomerByID("Jim");

            bool removeResult = repo.DeleteExisting(oldContent);

            //Assert
            Assert.IsTrue(removeResult);
        }
Ejemplo n.º 6
0
        public void UpdateExistingContent_ShouldReturnTrue()
        {
            //Arrange
            C5_Repo  repo       = new C5_Repo();
            C5Emails oldContent = new C5Emails("Jim", "Istired", "verytired", CustomerType.Past);

            repo.AddToList(oldContent);

            C5Emails newContent = new C5Emails("James", "Is", "verytired", CustomerType.Past);

            //Act
            bool updateResult = repo.UpdateExistingCustomer(oldContent.ID, newContent);

            //Assert
            Assert.IsTrue(updateResult);
        }
Ejemplo n.º 7
0
        public void GetDirectory_ShouldReturnCorrectCollection()
        {
            //Arrange
            C5Emails content = new C5Emails();
            C5_Repo  repo    = new C5_Repo();

            repo.AddToList(content);

            //Act
            List <C5Emails> contents = repo.GetCustomers();

            bool directoryHasContent = contents.Contains(content);

            //Assert
            Assert.IsTrue(directoryHasContent);
        }
Ejemplo n.º 8
0
            private void SeedContent()
            {
                C5Emails One = new C5Emails(
                    "A1",
                    "James",
                    "Gulley",
                    CustomerType.Potential
                    );
                C5Emails Two = new C5Emails(
                    "A2",
                    "Jim",
                    "Gulley",
                    CustomerType.Potential
                    );
                C5Emails Three = new C5Emails(
                    "A3",
                    "Jimmy",
                    "Brain",
                    CustomerType.Current
                    );
                C5Emails Four = new C5Emails(
                    "A4",
                    "Jimbob",
                    "Gollmister",
                    CustomerType.Current
                    );
                C5Emails Five = new C5Emails(
                    "A5",
                    "JimmyBoBob",
                    "Brain",
                    CustomerType.Past
                    );
                C5Emails Six = new C5Emails(
                    "A6",
                    "Pinky",
                    "Snarf",
                    CustomerType.Past
                    );

                repo.AddToList(One);
                repo.AddToList(Two);
                repo.AddToList(Three);
                repo.AddToList(Four);
                repo.AddToList(Five);
                repo.AddToList(Six);
            }
Ejemplo n.º 9
0
            private void DeleteCustomerByID()
            {
                ShowCustomers();
                Console.WriteLine("Enter the ID for the customer you would like to delete.");
                string customerIDToDelete = Console.ReadLine();

                C5Emails customerToDelete = repo.GetCustomerByID(customerIDToDelete);
                bool     wasDeleted       = repo.DeleteExisting(customerToDelete);

                if (wasDeleted)
                {
                    Console.WriteLine("This content was successfully deleted.");
                }
                else
                {
                    Console.WriteLine("Content could not be deleted");
                }
            }
Ejemplo n.º 10
0
            private void ShowCustomerByID()
            {
                Console.Clear();
                Console.WriteLine("Enter the title of the content you'd like to see.");
                string id = Console.ReadLine();

                C5Emails customer = repo.GetCustomerByID(id);

                if (customer != null)
                {
                    ShowCustomer(customer);
                }
                else
                {
                    Console.WriteLine("That title doesn't exist.");
                }
                Console.ReadKey();
            }
Ejemplo n.º 11
0
 public void ShowCustomer(C5Emails customer)
 {
     Console.WriteLine($"Customer ID: {customer.ID}");
     Console.WriteLine($"Customer FirstName: {customer.FirstName}");
     Console.WriteLine($"Customer LastName: {customer.LastName}");
     Console.WriteLine($"Customer Type: {customer.CustomerType}");
     if (customer.CustomerType == CustomerType.Current)
     {
         Console.WriteLine("Thank you for your work with us. We appreciate your loyalty. Here's a coupon.");
     }
     else if (customer.CustomerType == CustomerType.Past)
     {
         Console.WriteLine("It's been a long time since we've heard from you, we want you back");
     }
     else if (customer.CustomerType == CustomerType.Potential)
     {
         Console.WriteLine("We currently have the lowest rates on Helicopter Insurance!");
     }
 }