Ejemplo n.º 1
0
        public HttpResponseMessage ModifyPrivilege(HttpRequestMessage request, Privilege privilege)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                if (!ModelState.IsValid)
                {
                    response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    string msg = _prilegeService.ModifyPrivilege(privilege);
                    if (msg == "成功!")
                    {
                        response = request.CreateResponse <Privilege>(HttpStatusCode.Created, privilege);
                    }

                    response = request.CreateResponse(HttpStatusCode.Created, new { message = "失败!", data = msg });
                }

                return response;
            }));
        }