public HttpResponseMessage Post(HttpRequestMessage request, Fan f) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (ModelState.IsValid) { request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } else { var fan = _fanService.Add(f); _fanService.SaveChanges(); response = request.CreateResponse(HttpStatusCode.Created, fan); } return response; })); }