Пример #1
0
        public IEnumerable <MovieViewModel> GetMovies(int skippedItems = 0, int takenItems = 0)
        {
            var movies = Database.GetRepository <Movie>().GetAll();

            takenItems = takenItems == 0 ? movies.Count() : takenItems;
            return(movies.Skip(skippedItems).Take(takenItems).Select(m => MovieViewModel.FromMovie(m)).ToList());
        }
Пример #2
0
        public IEnumerable <MovieViewModel> GetMoviesByUserId(string UserId, int skippedItems = 0, int takenItems = 0)
        {
            var movies = Database.GetRepository <Movie>().GetAll().Where(m => m.UserProfile.ApplicationUser.Id == UserId);

            takenItems = takenItems == 0 ? movies.Count() : takenItems;
            return(movies.Skip(skippedItems).Take(takenItems).Select(m => MovieViewModel.FromMovie(m)).ToList());
        }
Пример #3
0
        public MovieViewModel GetMovieById(int id)
        {
            var movie = Database.GetRepository <Movie>().FindById(id)
                        ?? throw new ArgumentNullException($"Фильм c id {id} не найден");

            return(MovieViewModel.FromMovie(movie));
        }
Пример #4
0
 public IEnumerable <MovieViewModel> GetMovies(int skippedItems = 0, int takenItems = 0)
 => Database.MovieManager.GetMovies(skippedItems, takenItems).ToList().Select(m => MovieViewModel.FromMovie(m));
Пример #5
0
 public MovieViewModel GetMovieById(int id)
 => MovieViewModel.FromMovie(Database.MovieManager.GetMovieById(id));