private static void ExecuteAction(PrinterService printerService, IEnumerable <IPrinter> printers) { string value = System.Console.ReadLine(); if (int.TryParse(value, out int key)) { System.Console.Clear(); string name, model; switch (key) { case (int)Action.Add: GetPrinterInfo(out name, out model); printerService.Add(new Printer(name, model)); break; case (int)Action.Remove: GetPrinterInfo(out name, out model); printerService.Remove(new Printer(name, model)); break; default: int i = 1; if (printers.Count() != 0) { i++; } foreach (var printer in printers) { if (key == i) { System.Console.WriteLine("Data:"); var data = System.Console.ReadLine(); System.Console.WriteLine(printerService.Print(printer.Name, printer.Model, data)); } } break; } } }