コード例 #1
0
        public ActionResult EditOrCreateMovie(int movieId = 0)
        {
            if (Session["LoggedIn"] == null || Session["LoggedIn"].Equals(false))
            {
                return(RedirectToRoute(new
                {
                    controller = "Home",
                    action = "Index"
                }));
            }

            if (movieId == 0)
            {
                return(View(new MovieViewModel()));
            }

            var movie = _moviesLogic.GetMovie(movieId);

            if (movie != null)
            {
                var movieViewModel = ModelMapper.MapFromMovieBLLModelToMovieViewModel(movie);
                return(View(movieViewModel));
            }
            else
            {
                return(View(new MovieViewModel()));
            }
        }
コード例 #2
0
        public JsonResult NewRental(string movieId)
        {
            if ((bool)Session["LoggedIn"] != true)
            {
                // Ingen innlogget bruker; returnerer feil
                return(Json("UserError", JsonRequestBehavior.AllowGet));
            }

            try
            {
                string username = (string)Session["Username"];
                var    user     = _customerUsersLogic.Get(username);

                var movId = Int32.Parse(movieId);
                var movie = _moviesLogic.GetMovie(movId);

                var movieOrderModelBLL = new MovieOrderModelBLL()
                {
                    RentedMovieId        = movie.ID,
                    RentalStartTimeStamp = DateTime.Now.ToString("dd-MM-yyyy - HH:mm:ss"),
                    RentalUser           = user
                };

                _movieOrdersLogic.Create(movieOrderModelBLL);
            }
            catch (Exception ex)
            {
                return(Json("Some error occured", JsonRequestBehavior.AllowGet));
            }

            return(Json("OK", JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        public void GetMovieTest()
        {
            //Arrange
            var seedDB = new List <MovieModelDAL>();
            var seed   = new MovieModelDAL
            {
                ID         = 5050,
                Title      = "Movie",
                Year       = 2018,
                Rated      = "10",
                Runtime    = "20 min",
                Genre      = "Commedy",
                Director   = "Director",
                Plot       = "Some Plot",
                Poster     = "www.poster.com",
                ImdbRating = 10f,
                ScreenShot = "www.screenshot.com"
            };

            seedDB.Add(seed);
            var controller = new MoviesLogic(new MovieDALStub(seedDB));
            var rightInput = 5050;
            var wrongInput = -10;

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

            //Assert
            Assert.IsNotNull(result1);
            Assert.IsNull(result2);
        }
コード例 #4
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));
        }
コード例 #5
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"));
            }
        }