示例#1
0
        // POST api/ActiveGame
        public HttpResponseMessage Post(ActiveGame value)
        {
            if (ModelState.IsValid)
            {
                _activeGameRepository.InsertOrUpdate(value);
                _activeGameRepository.Save();

                //Created!
                var response = Request.CreateResponse <Core.ActiveGame>(HttpStatusCode.Created, value);

                //Let them know where the new ActiveGame is
                string uri = Url.Route(null, new { id = value.Id });
                response.Headers.Location = new Uri(Request.RequestUri, uri);

                return(response);
            }
            throw new HttpResponseException(HttpStatusCode.BadRequest);
        }