public HttpResponseMessage AddPrivilege(HttpRequestMessage request, PrivilegeViewModel roleview) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } else { Privilege my = new Privilege(); my.UpdatePrivilegeEntity(roleview); _prilegeService.AddPrivilege(my); response = request.CreateResponse <Privilege>(HttpStatusCode.Created, my); } return response; })); }