Beispiel #1
0
        public void GetUserMovieOrdersTest()
        {
            //Arrange
            var seedDB = new List <MovieOrderModelDAL>();
            var seed   = new MovieOrderModelDAL
            {
                RentedMovieId        = 1,
                ID                   = 1,
                RentalStartTimeStamp = DateTime.Now.ToString(),
                Email                = "*****@*****.**"
            };

            seedDB.Add(seed);
            var controller = new MovieOrdersLogic(new MovieOrderDALStub(seedDB));
            var rightInput = "*****@*****.**";
            var wrongInput = "";

            //Act
            var result1 = controller.GetUserMovieOrders(rightInput);
            var result2 = controller.GetUserMovieOrders(wrongInput);

            //Assert
            Assert.IsTrue(result1.Count == 1);
            Assert.IsTrue(result2.Count == 0);
        }
Beispiel #2
0
        public ActionResult Index(string email)
        {
            var orders = _movieOrdersLogic.GetUserMovieOrders(email);

            var movieOrderViewModels = new List <MovieOrderViewModel>();

            foreach (var entry in orders)
            {
                var movieOrderModal = new MovieOrderViewModel()
                {
                    ID = entry.ID,
                    RentalStartTimeStamp = entry.RentalStartTimeStamp,
                    RentedMovieId        = entry.RentedMovieId,
                    Email = email
                };

                var movie          = _moviesLogic.GetMovie(entry.RentedMovieId);
                var movieViewModel = ModelMapper.MapFromMovieBLLModelToMovieViewModel(movie);

                movieOrderModal.RentedMovie = movieViewModel;
                movieOrderViewModels.Add(movieOrderModal);
            }

            return(View(movieOrderViewModels));
        }
Beispiel #3
0
        public ActionResult Index()
        {
            var username = (string)Session["Username"];

            if (username == null || (bool)Session["LoggedIn"] != true)
            {
                return(RedirectToRoute(new
                {
                    controller = "Home",
                    action = "LogInModal"
                }));
            }

            try
            {
                var result   = _movieOrdersLogic.GetUserMovieOrders(username);
                var myMovies = new List <MovieRental>();

                foreach (var entry in result)
                {
                    var movieRental = new MovieRental()
                    {
                        RentedMovieId = entry.RentedMovieId
                    };

                    var movie = _moviesLogic.GetMovie(movieRental.RentedMovieId);

                    var newRentedMovie = new Movie()
                    {
                        Title      = movie.Title,
                        Year       = movie.Year,
                        Rated      = movie.Rated,
                        Runtime    = movie.Runtime,
                        Genre      = movie.Genre,
                        Director   = movie.Director,
                        Plot       = movie.Plot,
                        Poster     = movie.Poster,
                        ImdbRating = movie.ImdbRating,
                        ScreenShot = movie.ScreenShot
                    };

                    movieRental.RentedMovie = newRentedMovie;

                    myMovies.Add(movieRental);
                }

                return(View(myMovies));
            }
            catch (Exception)
            {
                return(View("ErrorPage"));
            }
        }