Exemple #1
0
        public HttpResponseMessage CarUpdate(int Id, CarUpdate updateRequest)
        {
            CarsService carsService = new CarsService();

            if (updateRequest == null)
            {
                ModelState.AddModelError("", "missing model");
            }
            else if (Id != updateRequest.Id)
            {
                ModelState.AddModelError("Id", "id does not match URL");
            }

            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            carsService.CarUpdate(updateRequest);
            return(Request.CreateResponse(HttpStatusCode.OK));
        }