// GET /api/cars/{id} public Car GetCar(int id) { var carTuple = _carsCtx.GetSingle(id); if (!carTuple.Item1) { var response = Request.CreateResponse(HttpStatusCode.NotFound); throw new HttpResponseException(response); } return(carTuple.Item2); }
public Car Get(int id) { var car = _carsContext.GetSingle(x => x.Id == id); if (car == null) { var response = new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent("Contact not found") }; throw new HttpResponseException(response); } return(car); }
public Car GetCar(int id) { return(_carsContext.GetSingle(car => car.Id == id)); }