public void UpdateExistingContent()
        {
            Console.Clear();
            Console.WriteLine("Enter the name of the person's data you'd like to update.");
            string          firstName = Console.ReadLine();
            CustomerContent oldItem   = _repo.FindPersonByName(firstName);

            if (oldItem == null)
            {
                Console.WriteLine("Person not found, press any key to continue...");
                Console.ReadKey();
                return;
            }
            CustomerContent newItem = new CustomerContent(
                oldItem.FirstName,
                oldItem.LastName,
                oldItem.Type,
                oldItem.Email
                );

            Console.WriteLine("Which property would you like to update:\n" +
                              "1. First Name\n" +
                              "2. Last Name\n" +
                              "3. Type\n" +
                              "4. Email Message\n" +
                              "6. Nevermind");
            string selection = Console.ReadLine();

            switch (selection)
            {
            case "1":
                Console.WriteLine("Enter a new title");
                string newFirstName = Console.ReadLine();
                newItem.FirstName = newFirstName;
                bool wasSuccessful = _repo.UpdateExistingContent(firstName, newItem);
                if (wasSuccessful)
                {
                    Console.WriteLine("Name successfully updated");
                }
                else
                {
                    Console.WriteLine($"Error: Could not update {firstName}");
                }
                break;

            default:
                break;
            }
        }
Esempio n. 2
0
        public void UpdateExistingContent_ShouldReturnTrue()
        {
            //Arrange
            CustomerContent_Repo repo       = new CustomerContent_Repo();
            CustomerContent      oldContent = new CustomerContent("Toy Story", "Toys come to life", 10, Genre.Action, MaturityRating.PG);

            repo.AddContentToDirectory(oldContent);

            CustomerContent newContent = new CustomerContent("Toy Story", "Toys come to life", 10, Genre.Action, MaturityRating.PG);

            //Act
            bool updateResult = repo.UpdateExistingContent("Toy Story", newContent);

            //Assert
            Assert.IsTrue(updateResult);
        }