Exemplo n.º 1
0
        public static void DeleteMagazine()
        {
            HeaderMenu.Show();
            Console.WriteLine("You are at: > Magazines > Delete magazines.");
            Console.WriteLine("");

            Console.Write("Type the ID of the magazine you want to delete:");
            int      id       = Convert.ToInt32(Console.ReadLine());
            Magazine magazine = MagazinesRepository.Find(id);

            if (magazine != null)
            {
                Console.WriteLine($"You have selected: {magazine.Title}");
                Console.WriteLine("");

                MagazinesRepository.Delete(magazine);

                Console.WriteLine("");
                Console.WriteLine("Magazine deleted successfully!");
                Console.WriteLine("");

                Console.WriteLine("Press any key to return.");
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine("Error. Invalid ID.");
                Console.WriteLine("Press any key to return.");
                Console.ReadKey();
                return;
            }
        }
Exemplo n.º 2
0
 public string Delete(int id)
 {
   Magazine exists = _repo.Get(id);
   if (exists == null)
   {
     throw new Exception("Invalid Id");
   }
   //if you are the creator
   if (_repo.Delete(id))
   {
     return "Success";
   }
   throw new Exception("Something went wrong with deleting that item");
 }