// PUT api/ChallengeMatche/5
 public HttpResponseMessage Put(int id, ChallengeMatch value)
 {
     if (ModelState.IsValid)
     {
         _challengeMatchRepository.InsertOrUpdate(value);
         _challengeMatchRepository.Save();
         return(new HttpResponseMessage(HttpStatusCode.NoContent));
     }
     throw new HttpResponseException(HttpStatusCode.BadRequest);
 }
Ejemplo n.º 2
0
 public void InsertOrUpdate(ChallengeMatch challengematch)
 {
     if (challengematch.Id == default(int))
     {
         // New entity
         context.ChallengeMatches.Add(challengematch);
     }
     else
     {
         // Existing entity
         context.Entry(challengematch).State = EntityState.Modified;
     }
 }
        // POST api/ChallengeMatche
        public HttpResponseMessage Post(ChallengeMatch value)
        {
            if (ModelState.IsValid)
            {
                _challengeMatchRepository.InsertOrUpdate(value);
                _challengeMatchRepository.Save();

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

                //Let them know where the new ChallengeMatche 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);
        }