示例#1
0
        public HttpResponseMessage PostClaim(Claim claim)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    claimRepository.Insert(claim);
                }
                catch(DbUpdateException)
                {

                }
                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, claim);
                return response;
            }
            return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
        }
示例#2
0
        public HttpResponseMessage PutClaim(string id, Claim claim)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            if (id != claim.Name)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }