// PUT /api/notatwitterapi/5
 public HttpResponseMessage Put(int id, NotATweet value)
 {
     if (ModelState.IsValid)
     {
         notatweetRepository.InsertOrUpdate(value);
         notatweetRepository.Save();
         return(new HttpResponseMessage(HttpStatusCode.NoContent));
     }
     throw new HttpResponseException(HttpStatusCode.BadRequest);
 }
示例#2
0
 public ActionResult Edit(NotATweet notatweet)
 {
     if (ModelState.IsValid)
     {
         notatweetRepository.InsertOrUpdate(notatweet);
         notatweetRepository.Save();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View());
     }
 }
        // POST /api/notatwitterapi
        public HttpResponseMessage Post(NotATweet value)
        {
            if (ModelState.IsValid)
            {
                notatweetRepository.InsertOrUpdate(value);
                notatweetRepository.Save();

                //Created!
                //var response = new HttpResponseMessage<NotATweet>( value, HttpStatusCode.Created );
                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, value);

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