public HttpResponseMessage Delete(HttpRequestMessage request, int id) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } else { _warrantyService.Delete(id); _warrantyService.SaveChanges(); response = request.CreateResponse(HttpStatusCode.OK); } return response; })); }