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; } }
public static void AddMagazine() { HeaderMenu.Show(); Console.WriteLine("You are at: > Magazines > Add new Magazine."); Console.WriteLine(""); Magazine magazine = new Magazine(); Console.Write("Insert magazine title:"); magazine.Title = Console.ReadLine(); Console.Write("Insert magazine price:"); magazine.Price = Convert.ToDecimal(Console.ReadLine()); MagazinesRepository.Insert(magazine); Console.WriteLine(""); Console.WriteLine("Magazine inserted successfully!"); Console.WriteLine(""); Console.WriteLine("Press any key to return."); Console.ReadKey(); }
public static void ListMagazine() { HeaderMenu.Show(); Console.WriteLine("You are at: > Magazines > List all magazines"); Console.WriteLine(""); Console.WriteLine($"╔{new string('═', 109)}╗"); Console.WriteLine($"║ MAGAZINES LIST{new string(' ', 94)}║"); Console.WriteLine($"╠═{new string('═', 3)}═╦═{new string('═', 20)}═╦═{new string('═', 40)}═╦═{new string('═', 10)}═╦═{new string('═', 10)}═╦═{new string('═', 9)}═╣"); Console.WriteLine($"║ {"ID",-3} ║ {"Category",-20} ║ {"Title",-40} ║ {"Publisher",-10} ║ {"Stock qty.",-10} ║ {"Price",-9} ║"); Console.WriteLine($"╠═{new string('═', 3)}═╬═{new string('═', 20)}═╬═{new string('═', 40)}═╬═{new string('═', 10)}═╬═{new string('═', 10)}═╬═{new string('═', 9)}═╣"); foreach (var magazine in MagazinesRepository.List()) { Console.WriteLine($"║ {magazine.ID,3} ║ {magazine.Category,-20} ║ {magazine.Title,-40} ║ {magazine.Publisher,-10} ║ {magazine.StockQuantity,10} ║ {magazine.Price,9:N2} ║"); } Console.WriteLine($"╚═{new string('═', 3)}═╩═{new string('═', 20)}═╩═{new string('═', 40)}═╩═{new string('═', 10)}═╩═{new string('═', 10)}═╩═{new string('═', 9)}═╝"); Console.WriteLine(""); Console.WriteLine("Press any key to return to magazines main menu..."); Console.ReadKey(); Show(); }
public MagazineService(MagazinesRepository repo) { _repo = repo; }
public frmListMagazines() { InitializeComponent(); magazinesRepository = new MagazinesRepository(); }