private void DeleteContent() { Console.Clear(); Console.ForegroundColor = ConsoleColor.Black; Console.BackgroundColor = ConsoleColor.Red; Console.WriteLine("------Deleting Conent------"); Console.ResetColor(); Console.WriteLine("Currently Available Titles:"); List <StreamingContent> listOfContent = _repo.GetContents(); //Display all titles in the repo foreach (StreamingContent content in listOfContent) { Console.WriteLine(content.Title); } Console.WriteLine("---------------------------"); Console.WriteLine("Please enter the title you would like to delete:"); string titleToDelete = Console.ReadLine(); StreamingContent contentToDelete = _repo.GetContentByTitle(titleToDelete); Console.Clear(); Console.ForegroundColor = ConsoleColor.Black; Console.BackgroundColor = ConsoleColor.Red; Console.WriteLine("------Deleting Conent------"); Console.ResetColor(); DisplayContent(contentToDelete); Console.WriteLine("---------------------------"); Console.WriteLine("Continue? (Type 'yes' or 'no')"); string continueUpdate = Console.ReadLine(); if (continueUpdate.ToLower() == "yes" || continueUpdate.ToLower() == "y") { bool wasDeleted = _repo.DeleteExistingContent(contentToDelete); //Delete repo if (wasDeleted == true) { Console.WriteLine("Your Content was successfully updated."); Console.WriteLine("Press any key to return to menu."); } else { Console.WriteLine("Opps. Something went wrong. Your Content was not added. Please try again"); Console.WriteLine("Press any key to return to menu."); } Console.ReadKey(); } else { Console.WriteLine("Deletion canceled. Press any key to return to Main Menu"); Console.ReadKey(); } }
public void DeleteExistingContent_ShouldReturnTrue() { //Arrange StreamingContent_Repo repo = new StreamingContent_Repo(); StreamingContent content = new StreamingContent("Toy Story", "Toys come to life", 8, Genre.Drama, MaturityRating.PG); repo.AddContentToDirectory(content); //Act StreamingContent oldContent = repo.GetContentByTitle("Toy Story"); bool removeResult = repo.DeleteExistingContent(oldContent); //Assert Assert.IsTrue(removeResult); }
private void DeleteContentByTitle() { ShowAllContent(); Console.WriteLine("Enter the title for the content you would like to delete."); string titleToDelete = Console.ReadLine(); StreamingContent contentToDelete = _repo.GetContentByTitle(titleToDelete); bool wasDeleted = _repo.DeleteExistingContent(contentToDelete); if (wasDeleted) { Console.WriteLine("This content was successfully deleted."); } else { Console.WriteLine("Content could not be deleted"); } }
//method that prompts user for which streamingContent object they want to delete //remove it from the _contentDirectory. //Bonus: Display all the options fro them to select from private void DeleteContentByTitle() { Console.Clear(); ShowAllContent(); Console.WriteLine("What would you like to delete?"); string title = Console.ReadLine(); StreamingContent contentToDelete = _repo.GetContentByTitle(title); bool wasDeleted = _repo.DeleteExistingContent(contentToDelete); if (wasDeleted) { Console.WriteLine("This content was deleted."); } else { Console.WriteLine("Content could not be deleted."); } }