Ejemplo n.º 1
0
        public async Task <IActionResult> ListByGenre(int genreId)
        {
            var client  = _clientFactory.CreateClient();
            var request = new HttpRequestMessage(HttpMethod.Get, $"{MovieAPIRoot}GetMoviesByGenre/{genreId}");

            request.Headers.Add("Accept", "application/json");
            request.Headers.Add("User-Agent", "DotNetflix.Web");

            var response = await client.SendAsync(request);

            if (response.IsSuccessStatusCode)
            {
                using (var responseStream = await response.Content.ReadAsStreamAsync())
                {
                    var movies = await JsonSerializer.DeserializeAsync <IEnumerable <Movie> >(responseStream,
                                                                                              new JsonSerializerOptions()
                    {
                        PropertyNameCaseInsensitive = true
                    });

                    var vm = new MovieListViewModel()
                    {
                        Movies = movies
                    };
                    return(View(vm));
                }
            }
            // GET LIST OF MOVIES BASED ON GENRE ID AND RETURN IN VIEW.
            // LIST SHOULD BE LIMITED TO < 100 Results.

            return(View());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> List(string title)
        {
            if (string.IsNullOrEmpty(title))
            {
                title = "abc";
            }

            var client  = _clientFactory.CreateClient();
            var request = new HttpRequestMessage(HttpMethod.Get, $"{MovieAPIRoot}getmovies/{title}");

            request.Headers.Add("Accept", "application/json");
            request.Headers.Add("User-Agent", "DotNetflix.Web");

            var response = await client.SendAsync(request);

            if (response.IsSuccessStatusCode)
            {
                using var responseStream = await response.Content.ReadAsStreamAsync();

                var movies = await JsonSerializer.DeserializeAsync <IEnumerable <Movie> >(responseStream,
                                                                                          new JsonSerializerOptions()
                {
                    PropertyNameCaseInsensitive = true
                });

                var vm = new MovieListViewModel()
                {
                    Movies = movies
                };

                return(View(vm));
            }
            return(View(new MovieListViewModel()));
        }
Ejemplo n.º 3
0
 public SearchPage(MovieListViewModel viewModel)
 {
     this._viewModel = viewModel;
     this._viewModel.SetNavigation(this.Navigation);
     this.BindingContext = this._viewModel;
     InitializeComponent();
 }
Ejemplo n.º 4
0
 public PopularMoviesPage(MovieService api)
 {
     this._api           = api;
     _movieListViewModel = new MovieListViewModel(this.Navigation, _api, "Most Popular");
     this.BindingContext = this._movieListViewModel;
     InitializeComponent();
 }
Ejemplo n.º 5
0
        public List <MovieListViewModel> getAllMovies()
        {
            List <MovieListViewModel> listMovieVM = new List <MovieListViewModel>();
            MovieListViewModel        MLVM        = new MovieListViewModel();

            MLVM.List = new List <Movie>();
            Movie tempMovie = new Movie
            {
                Title     = "Gjøkeredet",
                Genre     = "Drama",
                Stars     = 8.7,
                Storyline = "McMurphy plasseres på et sinnssykehus hvor alle pasientene er sløvet ned av" +
                            "medikamenter og underkastet sykehusledelsen og oversøster Ratched." +
                            "McMurphy gjør opprør fra første stund og etterhvert får han de andre pasientene med seg. " +
                            "Hans opprør tas imidlertid ille opp av stedets ledelse og de ser seg derfor nødt til å knekke ham.",
                ContentRating = "15",
                ReleaseYear   = "1975",
                Price         = 80.00,
                Poster        = "https://m.media-amazon.com/images/M/MV5BZjA0OWVhOTAtYWQxNi00YzNhLWI4ZjYtNjFjZTEyYjJlNDVlL2ltYWdlL2ltYWdlXkEyXkFqcGdeQXVyMTQxNzMzNDI@._V1_SY1000_CR0,0,672,1000_AL_.jpg",
                Director      = "Milos Forman",
                Duration      = "132 min"
            };

            MLVM.List.Add(tempMovie);
            MLVM.List.Add(tempMovie);
            MLVM.List.Add(tempMovie);
            listMovieVM.Add(MLVM);
            return(listMovieVM);
        }
Ejemplo n.º 6
0
        public ActionResult Index([ModelBinder(typeof(GridBinder))] GridOptions options, string searchString, string SearchFranchise)
        {
            options.TotalItems = LibraryService.SearchMoviesCount("");
            if (options.SortColumn == null)
            {
                options.SortColumn = "ID";
            }
            var model = new MovieListViewModel();

            if (!String.IsNullOrEmpty(searchString))
            {
                model.GridOptions = options;
                model.Movies      = LibraryService.SearchMovies(searchString, (options.Page - 1) * options.ItemsPerPage, options.ItemsPerPage, options.SortColumn, options.SortDirection).ToList();
            }
            else if (!String.IsNullOrEmpty(SearchFranchise))
            {
                model.GridOptions = options;
                model.Movies      = LibraryService.SearchMoviesByFranchise(SearchFranchise, (options.Page - 1) * options.ItemsPerPage, options.ItemsPerPage, options.SortColumn, options.SortDirection).ToList();
            }
            else
            {
                model.GridOptions = options;
                model.Movies      = LibraryService.SortMovies((options.Page - 1) * options.ItemsPerPage, options.ItemsPerPage, options.SortColumn, options.SortDirection).ToList();
            }

            return(View(model));
        }
        public ActionResult Index([ModelBinder(typeof(GridBinder))] GridOptions options, string searchText)
        {
            if (searchText != null)
            {
                options.SearchText = searchText;
                options.Page       = 1;
            }
            else
            {
                options.SearchText = options.SearchText ?? "";
            }

            options.TotalItems = LibraryService.SearchMoviesCount(options.SearchText);

            if (options.SortColumn == null)
            {
                options.SortColumn = "ID";
            }

            var movies = LibraryService.SearchMovies(options.SearchText ?? "",
                                                     (options.Page - 1) * options.ItemsPerPage,
                                                     options.ItemsPerPage,
                                                     options.SortColumn,
                                                     options.SortDirection).ToList();

            var model = new MovieListViewModel
            {
                GridOptions = options,
                Movies      = movies
            };

            return(View(model));
        }
        public ActionResult MovieList()
        {
            List <Movie> movieList = new List <Movie>
            {
                new Movie {
                    Name = "Bill and Teds bogus journey"
                },
                new Movie {
                    Name = "Dr Strange. "
                },
                new Movie {
                    Name = "Stalker"
                },
                new Movie {
                    Name = "Yakkity sax"
                }
            };


            var viewModel = new MovieListViewModel {
                MovieList = movieList
            };



            return(View(viewModel));
        }
Ejemplo n.º 9
0
 public XFMovieSearchPage(MovieServices movieService)
 {
     this._movieService  = movieService;
     this._viewModel     = new MovieListViewModel(this.Navigation, this._movieService);
     this.BindingContext = this._viewModel;
     InitializeComponent();
 }
Ejemplo n.º 10
0
 public MovieListPage(FilmCollection Movie)
 {
     MovieDbFactory.RegisterSettings(Movie);
     this._movieListViewModel = new MovieListViewModel(this.Navigation, Movie._movies);
     this.BindingContext      = this._movieListViewModel;
     InitializeComponent();
 }
Ejemplo n.º 11
0
 public void SetUp()
 {
     _movieRepositoryMock   = new Mock <IMovieRepository>();
     _navigationServiceMock = new Mock <INavigationService>();
     _sut = new MovieListViewModel(_movieRepositoryMock.Object, _navigationServiceMock.Object);
     _movieListViewMock = new Mock <MovieListViewModel>();
 }
Ejemplo n.º 12
0
        public void UsableMovieRepo()
        {
            // Arrange
            Mock <IMovieRepository> mock = new Mock <IMovieRepository>();

            mock.Setup(m => m.Movies).Returns((new Movie[]
            {
                new Movie {
                    Id = 1, Title = "Title1"
                },
                new Movie {
                    Id = 2, Title = "Title2"
                },
                new Movie {
                    Id = 3, Title = "Title3"
                },
            }).AsQueryable <Movie>());

            MoviesController controller = new MoviesController(mock.Object);

            // Act
            MovieListViewModel result =
                controller.Overview().ViewData.Model as MovieListViewModel;

            // Assert
            Movie[] movieArray = result.Movies.ToArray();
            Assert.True(movieArray.Length == 3);
            Assert.Equal("Title1", movieArray[0].Title);
            Assert.Equal("Title2", movieArray[1].Title);
            Assert.Equal("Title3", movieArray[2].Title);
        }
Ejemplo n.º 13
0
        public TopRatedPage(MovieService api)
        {
            this._api           = api;
            _movieListViewModel = new MovieListViewModel(this.Navigation, _api, "Top Rated");
            this.BindingContext = this._movieListViewModel;

            InitializeComponent();
        }
Ejemplo n.º 14
0
        public MovieListPage()
        {
            this.InitializeComponent();

            _vm = new MovieListViewModel();

            this.DataContext = _vm;
        }
Ejemplo n.º 15
0
        public MainWindow(MovieListViewModel viewModel)
        {
            InitializeComponent();

            base.DataContext = viewModel;

            Dispatcher.ShutdownStarted += viewModel.OnProgramShutdownStarted;
        }
Ejemplo n.º 16
0
 public MainPage(MovieService api)
 {
     _api = api;
     _movieListViewModel = new MovieListViewModel(this.Navigation, _api, null);
     this.BindingContext = this._movieListViewModel;
     _movieList          = new List <MovieDetail>();
     InitializeComponent();
 }
Ejemplo n.º 17
0
 public TitleSearchPage(MovieController movieController, MovieListViewModel viewModel)
 {
     this.viewModel        = viewModel;
     this._movieController = movieController;
     this.viewModel.SetNavigation(Navigation);
     this.BindingContext = viewModel;
     InitializeComponent();
 }
        public IActionResult GoToEdit(MovieListViewModel model)
        {
            Movie editedMovie = new Movie();

            editedMovie = context.Movies.Find(model.MovieId);

            return(View("EditMovie", editedMovie));
        }
Ejemplo n.º 19
0
        //
        // GET: /Home/Index/
        public ActionResult Index(int offset = 0)
        {
            HomeViewModel model = new HomeViewModel();
            //MR_DataClassesDataContext _db = new MR_DataClassesDataContext();
            MRDataEntities _db = new MRDataEntities();

            var dis = _db.tbl_Discovery.OrderByDescending(d => d.disc_Flag).ToList();

            if (offset >= dis.Count || offset < 0)
            {
                return(Redirect("/Home/Index?offset=0"));
            }
            model.Discovery        = new HomeDiscViewModel(dis[offset]);
            model.Discovery.Offset = offset;
            model.Discovery.Post   = offset - 1;
            model.Discovery.Pre    = offset + 1;
            if (User.Identity.IsAuthenticated)
            {
                model.Discovery.Movie.IsPlan   = MarkManager.Validate(model.Discovery.Movie.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 1);
                model.Discovery.Movie.IsFinish = MarkManager.Validate(model.Discovery.Movie.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 2);
                model.Discovery.Movie.IsFavor  = MarkManager.Validate(model.Discovery.Movie.Id, AccountManager.GetId(CookieHepler.GetCookie("user")), 3);
            }

            var newmovie = _db.tbl_Movie.Where(m => m.movie_Status == 2).OrderByDescending(m => m.movie_Time).ToList().Take(20);

            model.News = new List <MovieListViewModel>();
            foreach (var item in newmovie)
            {
                MovieListViewModel movie = new MovieListViewModel();
                movie.Title = item.movie_Title;
                if (!string.IsNullOrEmpty(item.movie_TitleEn) && !string.IsNullOrWhiteSpace(item.movie_TitleEn))
                {
                    movie.Title += "\t" + item.movie_TitleEn;
                }
                movie.Year = item.movie_Year;
                movie.Id   = item.movie_Id;
                model.News.Add(movie);
            }

            var mostmovie = _db.tbl_Movie.Where(m => m.movie_Status == 2).OrderByDescending(m => m.movie_VisitCount).ToList().Take(20);

            model.Mosts = new List <MovieListViewModel>();
            foreach (var item in mostmovie)
            {
                MovieListViewModel movie = new MovieListViewModel();
                movie.Title = item.movie_Title;
                if (!string.IsNullOrEmpty(item.movie_TitleEn) && !string.IsNullOrWhiteSpace(item.movie_TitleEn))
                {
                    movie.Title += "\t" + item.movie_TitleEn;
                }
                movie.Year = item.movie_Year;
                movie.Id   = item.movie_Id;
                model.Mosts.Add(movie);
            }

            return(View(model));
        }
        public ActionResult DisplayMovies()
        {
            MovieListViewModel movies = new MovieListViewModel();

            movies.Movies = _context.Movies.Include(c => c.GenreType).ToList();


            return(View(movies));
        }
Ejemplo n.º 21
0
        public ActionResult Index()
        {
            var movieListViewModel = new MovieListViewModel
            {
                Movies = _movieService.GetAll()
            };

            return(View(movieListViewModel));
        }
Ejemplo n.º 22
0
        public ActionResult Index()
        {
            var viewModel = new MovieListViewModel()
            {
                Movies = movieList
            };

            return(View(viewModel));
        }
Ejemplo n.º 23
0
        public ViewResult Search(string searchQuery)
        {
            MovieListViewModel movieListViewModel = new MovieListViewModel()
            {
                Movies    = _movieRepository.SearchMovie(searchQuery),
                PageTitle = $"Results for {searchQuery}"
            };

            return(View(movieListViewModel));
        }
Ejemplo n.º 24
0
        public ViewResult Index(int?page)
        {
            MovieListViewModel movieListViewModel = new MovieListViewModel()
            {
                MoviesPaged = _movieRepository.GetAllMoviesForListPage().ToPagedList(page ?? 1, 20),
                PageTitle   = "All Movies"
            };

            return(View(movieListViewModel));
        }
Ejemplo n.º 25
0
        public IActionResult List()
        {
            var Movies             = _movieService.GetAll();
            var movieListViewModel = new MovieListViewModel()
            {
                movies = Movies
            };

            return(View(movieListViewModel));
        }
Ejemplo n.º 26
0
        public IActionResult List(String categoryName)
        {
            var Movies             = _movieService.GetMoviesByCategoryName(categoryName);
            var movieListViewModel = new MovieListViewModel()
            {
                movies = Movies
            };

            return(View(movieListViewModel));
        }
        public IActionResult DeleteMovie(MovieListViewModel model)
        {
            context.Movies.Remove(context.Movies.Find(model.MovieId));

            context.SaveChanges();

            return(View("MovieList", new MovieListViewModel
            {
                movies = context.Movies
            }));
        }
Ejemplo n.º 28
0
        public async Task <MovieListViewModel> GetAllMovieswithPagingAsync(int?pageCount, int?itemPerPage, string category)
        {
            var movies = await _movieRepository.GetPagingwithMoviesAsync(pageCount, itemPerPage, category);

            var viewModel = new MovieListViewModel
            {
                Movies = movies
            };

            return(viewModel);
        }
Ejemplo n.º 29
0
        public async Task <MovieListViewModel> GetAllMoviesAsync()
        {
            var movies = await _movieRepository.GetFamousMovies();

            var viewModel = new MovieListViewModel
            {
                Movies = movies
            };

            return(viewModel);
        }
Ejemplo n.º 30
0
        public IActionResult RemoveMovie(MovieListViewModel model)
        {
            Context.Movies.Remove(Context.Movies.Find(model.MovieID));

            Context.SaveChanges();

            return(View("MovieList", new MovieListViewModel
            {
                Movies = Context.Movies
            }));
        }