public void UpdateCarType(RentalCarTypeUpdateRequest request) { using (var con = GetConnection()) { var cmd = con.CreateCommand(); cmd.CommandText = "CarTypes_Update"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id", request.Id); cmd.Parameters.AddWithValue("@CarType", request.CarType); cmd.ExecuteNonQuery(); } }
public HttpResponseMessage UpdateCarType(int id, RentalCarTypeUpdateRequest carTypeUpdateRequest) { if (carTypeUpdateRequest == null) { ModelState.AddModelError("", "Missing body data"); } else if (id != carTypeUpdateRequest.Id) { ModelState.AddModelError("id", "ID in URL does not match ID in body"); } if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } rentalCarsService.UpdateCarType(carTypeUpdateRequest); return(Request.CreateResponse(HttpStatusCode.OK)); }