private void RemoveContentFromList() { removeContent: //Ask the user which one they want to remove Console.Clear(); Console.WriteLine("Which item would you like to remove?"); //need a list of the items List <StreamingContent> contentList = _streamingRepo.GetContents(); int count = 0; foreach (var item in contentList) { count++; Console.WriteLine($"{count}) {item.Title}"); } //take in user response int TargetContentID = int.Parse(Console.ReadLine()); int correctIndex = TargetContentID - 1; if (correctIndex >= 0 && correctIndex < contentList.Count) { StreamingContent desiredContent = contentList[correctIndex]; if (_streamingRepo.DeleteExistingContent(desiredContent)) { Console.Clear(); Console.WriteLine($"{desiredContent.Title} successfully removed!"); } else { Console.WriteLine("I'm sorry, Dave. I'm afraid I can't do that."); } } else { Console.WriteLine("\nINVALID OPTION. \nDo you want to try another selection?\n1)Yes \n2)No"); string tryAgain = Console.ReadLine().ToLower(); switch (tryAgain) { case "1": goto removeContent; case "yes": goto removeContent; case "2": break; case "no": break; } } Console.WriteLine("Pres any key to continue...."); Console.ReadKey(); }
private void RemoveContentFromList() { _console.WriteLine("Which item would you like to remove?"); List <StreamingContent> contentList = _streamingRepo.GetContents(); int count = 0; foreach (StreamingContent content in contentList) { count++; _console.WriteLine($"{count}. {content.Title}"); } int targetContentID = int.Parse(_console.ReadLine()); int targetIndex = targetContentID - 1; if (targetIndex >= 0 && targetIndex < contentList.Count) { StreamingContent desiredContent = contentList[targetIndex]; if (_streamingRepo.DeleteExistingContent(desiredContent)) { _console.WriteLine($"{desiredContent.Title} successfully removed."); } else { _console.WriteLine("I'm sorry. I'm afraid I can't do that."); } } else { _console.WriteLine("No content has that ID"); } _console.WriteLine("Press any key to continue..."); _console.ReadKey(); }
} // if method is grayed out it is not being referenced private void RemoveContentFromList() //*? { _console.WriteLine("Which Title would you like to remove?"); // user prompt List <StreamingContent> contentList = _streamingRepo.GetContents(); // do not have to new up a list because it is being assigned a value of an existing list int count = 0; foreach (StreamingContent content in contentList) { count++; // increase the count by 1 _console.WriteLine($"{count} { content.Title}"); //this writes the increased count integer followed by the title of the content item that corralates to that title in the content list; } int targetContentId = int.Parse(_console.ReadLine()); // users string input is saved as an integer variable title targetContentId int targetIndex = targetContentId - 1; //integer with the variable targetIndex is equal to the userinput -1 thus an entry of three grabs the item number 2 because the count starts at 0 if (targetIndex >= 0 && targetIndex < contentList.Count) // if the targeted item is greater than or equal to zero and the number of items left on the list is greater than the total count of items on the list it will move to the { StreamingContent desiredContent = contentList[targetIndex]; // the object of the users desires to be remove is the idexed number in the content list. Which would be the number the user enter -1 if (_streamingRepo.DeleteExistingContent(desiredContent)) // if the item from the content list was successfully deleted { _console.WriteLine($"{desiredContent.Title} successfully removed."); // console Prints this message } else { _console.WriteLine("Desired action cannot be preformed."); //else if the items were not successfully deleted console will print this line } } else { _console.WriteLine("No content meets criteria"); // else if the user inputs and invalid repsonse } _console.WriteLine("Press any key...."); _console.ReadKey(); }
private void RemoveContentFromList() { _console.WriteLine("Which item would you like to remove?"); //need a list of items List <StreamingContent> contentList = _streamingRepo.GetContents(); int count = 0; foreach (var content in contentList) { count++; _console.WriteLine($"{count}) {content.Title}"); } //take in user response int targetContentID = int.Parse(_console.ReadLine()); int correctIndex = targetContentID - 1; if (correctIndex >= 0 && correctIndex < contentList.Count) { StreamingContent desiredContent = contentList[correctIndex]; if (_streamingRepo.DeleteExistingContent(desiredContent)) { _console.WriteLine($"{desiredContent.Title} successfully removed!"); } else { _console.WriteLine("I'm sorry Dave. I'm afriad I can't do that."); } } else { _console.WriteLine("Invalid Option"); } _console.WriteLine("Press any key to continue........."); _console.ReadKey(); }
// Get all streaming content info // Prompt user for individual content // Get individual content info // Remove content from list // Save updated list private void RemoveExistingContent() { _console.Clear(); _console.WriteLine("Enter the Title of the content you would like to delete."); string targetTitle = _console.ReadLine(); _streamingRepository.DeleteExistingContent(targetTitle); _console.WriteLine($"{targetTitle} has been successfully deleted\n" + $"Press any key to continue."); _console.ReadKey(); }
private void RemoveContentFromList() { // Prompt user Which Item to Remove from List. Console.WriteLine("Which Item Would You Like to Remove?"); // Need a List of Items. List <StreamingContent> contentList = _streamingRepository.GetContents(); int count = 0; foreach (var content in contentList) { count++; Console.WriteLine($"{count}) {content.Title}"); } // Take in user Response. int targetContentID = int.Parse(Console.ReadLine()); int correctIndex = targetContentID - 1; if (correctIndex >= 0 && correctIndex < contentList.Count) { StreamingContent desiredContent = contentList[correctIndex]; if (_streamingRepository.DeleteExistingContent(desiredContent)) { Console.WriteLine($"{desiredContent.Title} Has Been Removed!"); } else { Console.WriteLine("I'm sorry, Dave. I'm afraid I can't do that ..."); } } else { Console.WriteLine("Invalad Opiton!"); } Console.WriteLine("Press Any Key to Continue ..."); Console.ReadKey(); // Goal: Remove Item. }
private void RemoveContentFromList() { //prompt the user _console.WriteLine("Which item would you like to remove?"); //need a list of items List <StreamingContent> contentList = _streamingRepo.GetContent(); int count = 0; foreach (var content in contentList) { count++; _console.WriteLine($"{count}) {content.Title}"); } //take in user response int targetContentID = int.Parse(_console.ReadLine()); int correctIndex = targetContentID - 1; if (correctIndex >= 0 && correctIndex < contentList.Count) { StreamingContent desiredContent = contentList[correctIndex]; if (_streamingRepo.DeleteExistingContent(desiredContent)) { _console.WriteLine($"{desiredContent.Title} successfully removed."); } else { _console.WriteLine($"Was not able to remove {desiredContent.Title}."); } } else { _console.WriteLine("INVALID OPTION"); } _console.WriteLine("Press any key to continue..."); _console.ReadKey(); //Remove that item }