/// <summary> /// Will get a specific MovieOnList found by the Id /// </summary> /// <param name ="Id"></param> public HttpResponseMessage Get(int Id) { var movieOnList = facade.GetMovieOnListRepository().Get(Id); MovieOnListDTO movieOnListDTO = null; if (movieOnList != null) { movieOnListDTO = new MovieOnListConverter().Convert(movieOnList); return Request.CreateResponse<MovieOnListDTO>(HttpStatusCode.OK, movieOnListDTO); } var response = new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent(" MovieOnList not found.") }; throw new HttpResponseException(response); }
/// <summary> /// Creates a MovieOnList in the Database /// </summary> /// <param name="movieOnList"></param> /// <returns></returns> public HttpResponseMessage Post(MovieOnList movieOnList) { try { var movieOnListDTO = new MovieOnListConverter().Convert(movieOnList); facade.GetMovieOnListRepository().Add(movieOnList); var response = Request.CreateResponse<MovieOnListDTO>(HttpStatusCode.Created, movieOnListDTO); return response; } catch (Exception) { var response = new HttpResponseMessage(HttpStatusCode.Conflict) { Content = new StringContent("Could not add a movieOnList to the database") }; throw new HttpResponseException(response); } }
/// <summary> /// Updates a MovieOnList in Database /// </summary> /// <param name="movieOnList"></param> /// <returns></returns> public HttpResponseMessage Put(MovieOnList movieOnList) { try { var movieOnListDTO = new MovieOnListConverter().Convert(movieOnList); facade.GetMovieOnListRepository().Edit(movieOnList); var response = Request.CreateResponse<MovieOnListDTO>(HttpStatusCode.OK, movieOnListDTO); return response; } catch (Exception) { var response = new HttpResponseMessage(HttpStatusCode.Conflict) { Content = new StringContent("No matching movieOnList") }; throw new HttpResponseException(response); } }