public IHttpActionResult Get(int id) { Movie movie = MovieRepoStub.ReadById(id); if (movie == null) { return(NotFound()); } else { return(Ok(movie)); } }
public IHttpActionResult Delete(int id) { Movie m = MovieRepoStub.ReadById(id); if (m == null) { return(NotFound()); } MovieRepoStub.Delete(m.Id); return(Ok()); }
public IHttpActionResult Add(CreateMovieRequest req) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Movie m = new Movie { Title = req.Title, Rating = req.Rating }; MovieRepoStub.Create(m); return(Created($"movies/get/{m.Id}", m)); }
public IHttpActionResult Update(UpdateMovieRequest req) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Movie m = MovieRepoStub.ReadById(req.Id); if (m == null) { return(NotFound()); } m.Title = req.Title; m.Rating = req.Rating; MovieRepoStub.Update(m); return(Ok(m)); }
public IHttpActionResult All() { return(Ok(MovieRepoStub.ReadAll())); }