public void Handle(string commandLine) { try { Program.Logger.Info($"Processing the command \"{commandLine}\""); string[] args = commandLineSplitter.Split(commandLine); if (args.Length == 0) { return; } switch (args.First()) { case "cars": carsCommandHandler.ParseCommand(args.Skip(1).ToArray()); break; case "help": colorfulConsole.WriteLineFormatted("{0}", Color.Aquamarine, Color.WhiteSmoke, "Information:"); colorfulConsole.WriteLine("This console provides CLI (Command Line Interface) to operate with entities stored in the Database."); colorfulConsole.WriteLine(); colorfulConsole.WriteLineFormatted("- {0}", Color.GreenYellow, Color.WhiteSmoke, "cars list"); colorfulConsole.WriteLine(" Shows the full list of cars stored in the Database."); break; default: throw new ArgumentException($"Command \"{args.First()}\" not recognized. Use help command for more information."); } } catch (Exception exception) { Program.Logger.Error(exception); colorfulConsole.WriteLineFormatted("{0} " + exception.Message, Color.Red, Color.WhiteSmoke, "ERROR: "); } }
private void PrintEntitiesList() { List <Car> cars = carService.GetAll().ToList(); if (cars.Any()) { foreach (Car car in cars) { colorfulConsole.WriteLine($"Brand: {car.Brand}; Number: {car.Number}; Color: {car.Color}; Odometer: {car.Odometer}."); } colorfulConsole.WriteLine(string.Empty); } else { colorfulConsole.WriteLine("---- No Items ----"); } }