//get car by id public CarViewModel GetById(int id) { DBCarRent.Car car = null; using (CarsRepository carsRepository = new CarsRepository()) { car = carsRepository.GetCarById(id); } return(MapModelToViewModel(car)); }
public Car GetCarById(int id) { Car foundCar = _repo.GetCarById(id); if (foundCar == null) { throw new Exception("Invalid ID"); } return(foundCar); }