static void Main() { //TODO Need to Write Some Inpute and Business Roles Validation //TODO Need to Refactor for more Clean Code vehicleManager.CommandLineHelpInstruction(); while (true) { Console.WriteLine("Please Press Command"); int UserCommand; try { UserCommand = Convert.ToInt32(Console.ReadLine()); if (UserCommand == (int)Commandtype.Exit) { Console.WriteLine("You Press 4"); break; } else { vehicleManager.ExecuteCommand(UserCommand, ref vehicleManager, ref vehicles, ref TotalVisitor); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } Console.WriteLine(); Console.ReadKey(); }
public static void ExecuteCommand(int UserCommand, ref VehicleManager vehicleManager, ref List <Vehicle> vehicles, ref long TotalVisitor) { if (UserCommand == (int)Commandtype.Add) { vehicleManager.VehicleTypeSelectInstruction(); Int32 vehicleType = Convert.ToInt32(Console.ReadLine()); Vehicle vehicle = vehicleManager.GetVehicle((VehicleType)vehicleType); long VehicleNextId = vehicleManager.GetNextId(vehicles); vehicleManager.Add(vehicleManager.SetVechileData(vehicle, VehicleNextId, ref TotalVisitor), ref vehicles); } else if (UserCommand == (int)Commandtype.Remove) { Console.WriteLine("Use Vehicle Id for Remove Vehicle"); vehicleManager.ShowVechileList(vehicles); Console.WriteLine("Please Press Vehile Id"); object VehicleId = Convert.ToInt32(Console.ReadLine()); vehicleManager.Remove(VehicleId, ref vehicles); Console.WriteLine("Remove Success VehicleId=" + VehicleId); } else if (UserCommand == (int)Commandtype.ShowVehicleList) { vehicleManager.ShowVechileList(vehicles); } else if (UserCommand == (int)Commandtype.ShowVehicleListWithTotalVisitor) { Console.WriteLine("Total Visitor Is:" + TotalVisitor); vehicleManager.ShowVechileList(vehicles); } else if (UserCommand == (int)Commandtype.ClearCommandLine) { Console.Clear(); } else if (UserCommand == (int)Commandtype.CommandLineHelp) { vehicleManager.CommandLineHelpInstruction(); } else { Console.WriteLine("Please Press Command Between 1 and 5"); } }