Exemplo n.º 1
0
        public ReviewModelDTO SubmitReview(

            int movieId,

            ReviewModelDTO review
            )
        {
            try
            {
                using (IMovieDataSource _ds = new MovieDataSource(new MovieDbContext()))
                {
                    ReviewModelDTO currentReview = review;
                    MovieModel     movie         = _ds.GetMovies().Single(m => m.Id == movieId);
                    ReviewModel    rev           = new ReviewModel()
                    {
                        Rating = currentReview.Rating, ReviewText = currentReview.ReviewText, Reviewer = currentReview.Reviewer, Summary = currentReview.Summary, Movie = movie
                    };
                    movie.Reviews.Add(rev);
                    _ds.Save();
                    return(currentReview);
                }
            }
            catch (Exception e)
            {
                throw new FaultException(e.Source + Environment.NewLine + e.Message);
            }
        }