Exemple #1
0
 //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));
 }
Exemple #2
0
        public Car GetCarById(int id)
        {
            Car foundCar = _repo.GetCarById(id);

            if (foundCar == null)
            {
                throw new Exception("Invalid ID");
            }
            return(foundCar);
        }