Example #1
0
        public bool CreateMovieList(ListCreate model)
        {
            var entity =
                new MovieOnList()
            {
                MovieId      = model.MovieId,
                CollectionId = model.CollectionId,
                Comment      = model.Comment
            };

            using (var movieList = new ApplicationDbContext())
            {
                movieList.MovieOnLists.Add(entity);
                return(movieList.SaveChanges() == 1);
            }
        }
        /// <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);
     }
 }