private void EditDvd() { int id = view.SearchDvd(); bool exists = dvdRepository.exists(id); if (exists) { Dvd dvd = view.EditDvdInfo(dvdRepository.ReadById(id)); dvdRepository.Update(id, dvd); } else { Console.WriteLine("Entered Dvd Id doesn't exist!"); } }
public void Run() //TO DO: use while loop { Console.WriteLine("Welcome To Dvd Manager"); bool inChoice = false; while (!inChoice) { DvdView view = new DvdView(); int pass = view.GetMenuChoice(); if (pass == 1) { inChoice = true; CreateDvd(); Console.WriteLine("Press any key to go back."); Console.ReadKey(); inChoice = false; } else if (pass == 2) { inChoice = true; DisplayDvds(); Console.WriteLine("Press any key to go back."); Console.ReadKey(); inChoice = false; } else if (pass == 3) { inChoice = true; SearchDvds(); Console.WriteLine("Press any key to go back."); Console.ReadKey(); inChoice = false; } else if (pass == 4) { inChoice = true; var myEditId = new DvdView(); var myId = myEditId.SearchDvd(); var id = _dvds.ReadById(myId); //search in list repo if (id == null) { Console.WriteLine("Not in list."); } else { var getDvd = view.EditDvdInfo(id); EditDvd(myId, getDvd); } Console.WriteLine("Press any key to go back."); Console.ReadKey(); inChoice = false; } else if (pass == 5) { inChoice = true; RemoveDvd(); Console.WriteLine("Press any key to go back."); Console.ReadKey(); inChoice = false; } else { Console.WriteLine("Invalid input."); Console.ReadKey(); } } }