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); } }
public IList <MovieModelDTO> GetMoviesByTitle(string title) { using (IMovieDataSource _ds = new MovieDataSource(new MovieDbContext())) { IQueryable <MovieModel> result = _ds.GetMovies().Where(m => m.Title == title); return(result.Select(m => new MovieModelDTO() { Id = m.Id, Title = m.Title }).ToList()); } }
public MovieModelDTO GetMovie(int id) { using (IMovieDataSource _ds = new MovieDataSource(new MovieDbContext())) { MovieModel result; result = _ds.GetMovies().Single(m => m.Id == id); return(new MovieModelDTO() { Id = result.Id, Title = result.Title, ReleaseDate = result.ReleaseDate }); } }
public IList <MovieModelDTO> GetMovies() { using (IMovieDataSource _ds = new MovieDataSource(new MovieDbContext())) { IList <MovieModelDTO> result = _ds.GetMovies().Select(m => new MovieModelDTO() { Id = m.Id, Title = m.Title, ReleaseDate = m.ReleaseDate }).ToList <MovieModelDTO>(); return(result); } }