Exemplo n.º 1
0
        // 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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public Car GetCar(int id)
 {
     return(_carsContext.GetSingle(car => car.Id == id));
 }