// PUT api/movies/5 public void Put(Movie movieToUpdate) { // If can't find movie to update, then return status code 404 if (_repository.UpdateMovie(movieToUpdate) == false) { throw new HttpResponseException(HttpStatusCode.NotFound); } }
// POST api/movies public HttpResponseMessage Post(Movie movieToAdd) { // If new movie created, return Created response code _repository.AddMovie(movieToAdd); var response = Request.CreateResponse(HttpStatusCode.Created, movieToAdd); // Create URI for new movie string uri = Url.Link("DefaultApi", new { id = movieToAdd.Id }); response.Headers.Location = new Uri(uri); // Return the response return response; }
public bool UpdateMovie(Movie movieToUpdate) { return false; }
public void AddMovie(Movie movieToAdd) { movieToAdd.Id = 27; }