private void AddNewCourierVehicle() { if (!_userService.CheckIfThereIsAtLeastOnePossibleDriver()) { Console.WriteLine("\n" + "Database empty - there are no possible drivers!" + "\n"); return; } Console.WriteLine("\n" + "Adding a new vehicle to the system" + "\n"); var driver = _ioHelper.GetVehicleDriver(); if (!_userService.CheckIfCourierIsInDatabase(driver)) { Console.WriteLine("This courier is not in database!"); return; } if (_vehicleService.CheckIfCourierAlreadyHaveACar(driver)) { Console.WriteLine("This courier already have a car!"); return; } var newVehicle = new Vehicle { Brand = _ioHelper.GetTextFromUser("Enter vehicle's brand"), Model = _ioHelper.GetTextFromUser("Enter vehicle's model"), RegistrationNumber = _ioHelper.GetRegistrationNumberFromUser(), LoadCapacity = _ioHelper.GetIntFromUser("Enter vehicle's load capacity"), AverageVelocity = _ioHelper.GetIntFromUser("Enter vehicle's average velocity (in kilometers per hour)"), Driver = driver }; int metersInKilometer = 1000; newVehicle.AverageVelocity = newVehicle.AverageVelocity * metersInKilometer; if (_vehicleService.AddNewVehicleAsync(newVehicle).Result) { Console.WriteLine("\n" + "Vehicle added!"); } else { Console.WriteLine("\n" + "There has been an error while trying to add a vehicle"); } }
public void PostVehicle([FromBody] Vehicle vehicle) { _vehiclesService.AddNewVehicleAsync(vehicle); }