/// <summary> /// GET /Movies /// GET /Movies?Id={Id} /// </summary> /// <param name="request"></param> /// <returns></returns> public object Get(Movies request) { //Alternatively you can infer the HTTP method by inspecting the RequestContext attributes Log.InfoFormat("Using RequestContext to inspect Endpoint attributes: {0}", this.Request.RequestAttributes); var response = new MoviesResponse(); if (request.Id != null) { // GET /Movies?Id={request.Id} var movie = Db.SingleById<Movie>(request.Id); if (movie != null) { response.Movies.Add(movie); } } else { // GET /Movies response.Movies = Db.Select<Movie>(); } return response; }
/// <summary> /// POST /Movies /// </summary> /// <param name="request"></param> /// <returns></returns> public object Post(Movies request) { Db.Update(request.Movie); return new MoviesResponse(); }
/// <summary> /// DELETE /Movies /// </summary> /// <param name="request"></param> /// <returns></returns> public object Delete(Movies request) { Db.DeleteById<Movie>(request.Id); return new MoviesResponse(); }
/// <summary> /// PUT /Movies /// </summary> /// <param name="request"></param> /// <returns></returns> public object Put(Movies request) { Db.Insert(request.Movie); return new MoviesResponse(); }
public object Any(Movies request) { return Get(request); }