Esempio n. 1
0
        public async Task <ActionResult <Movie> > PostMovie([FromBody] URLDTO data)
        {
            Movie  movie;
            String movieTitle;

            try
            {
                movieTitle = data.URL;
                // Constructing the video object from our helper function
                movie = MovieDbHelper.GetMovieInfo(movieTitle);
            }
            catch
            {
                return(BadRequest("Cannot find requested movie"));
            }

            // Add this video object to the database
            _context.Movie.Add(movie);
            await _context.SaveChangesAsync();

            // Return success code and the info on the movie object
            return(CreatedAtAction("GetMovie", new { id = movie.MovieId }, movie));
        }
Esempio n. 2
0
        public async Task <ActionResult <Comments> > PostComments([FromBody] URLDTO data, int movieId)
        {
            String postedComment;

            try
            {
                postedComment = data.URL;
            }
            catch
            {
                return(BadRequest("Error posting comment"));
            }

            Comments newComment = new Comments
            {
                MovieId = movieId,
                Comment = postedComment
            };

            _context.Comments.Add(newComment);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetComments", new { id = newComment.CommentId }, newComment));
        }