Beispiel #1
0
        public HttpResponseMessage PostRegion(Region region)
        {
            if (ModelState.IsValid)
            {
                regionRepository.Insert(region);

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, region);
                return response;
            }
            return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
        }
Beispiel #2
0
        public HttpResponseMessage PutRegion(int id, Region region)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            if (id != region.RegionId)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
            regionRepository.Update(x => x.RegionId == id, region);

            return Request.CreateResponse(HttpStatusCode.OK);
        }