public ActionResult Create(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); }