Beispiel #1
0
        // PUT /api/cars/{id}
        public Car PutCar(int id, Car car)
        {
            car.Id = id;
            if (!_carsCtx.TryUpdate(car))
            {
                var response = Request.CreateResponse(HttpStatusCode.NotFound);
                throw new HttpResponseException(response);
            }

            return(car);
        }
Beispiel #2
0
        public Car Put(int id, Car car)
        {
            car.Id = id;
            if (!_carsContext.TryUpdate(car))
            {
                var response = new HttpResponseMessage(HttpStatusCode.NotFound)
                {
                    Content = new StringContent("Car not found")
                };

                throw new HttpResponseException(response);
            }

            return(car);
        }