Esempio n. 1
0
        public IActionResult EditMovieList(int?movieListId)
        {
            //Check user is authorised
            if (movieListId == null)
            {
                return(RedirectToAction("Profile", "User"));
            }

            var movieList = _efMovieListRepository.GetListById(movieListId.Value);

            if (movieList == null)
            {
                return(RedirectToAction("Profile", "User"));
            }

            if (movieList.UserId != Guid.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)))
            {
                return(Unauthorized());
            }

            var vm = new MoviesAndListViewModel()
            {
                MovieList = movieList,
                Movies    = _efMovieListRepository.GetAllMoviesInMovieList(movieList.Id)
            };

            return(View(vm));
        }
Esempio n. 2
0
        public IActionResult ViewList(int movieListId)
        {
            MoviesAndListViewModel moviesAndListView = new MoviesAndListViewModel
            {
                Movies    = _efMovieListRepository.GetAllMoviesInMovieList(movieListId),
                MovieList = _efMovieListRepository.GetListById(movieListId)
            };

            if (moviesAndListView.MovieList.IsPrivate &&
                moviesAndListView.MovieList.UserId != Guid.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)))
            {
                return(Forbid());
            }
            return(View(moviesAndListView));
        }