示例#1
0
        public IActionResult AddMovie(RentMovie movie)
        {
            string movieString = JsonSerializer.Serialize(movie);

            HttpContext.Session.SetString("RentMovieSession", movieString);

            return(View());
        }
示例#2
0
        public IActionResult Result(int ID, double Qty, string Title, string Genre, int Year, int RunTime, double RentalCost)
        {
            RentMovie movie = new RentMovie(ID, Qty, Title, Genre, Year, RunTime, RentalCost);

            if (ModelState.IsValid)
            {
                return(View(movie));
            }
            else
            {
                return(RedirectToAction("Registration", movie));
            }
        }
示例#3
0
 public void AddMovieToSession(string key, RentMovie movie, string type)
 {
     if (type == "shopping")
     {
         shoppingCart = GetSession(key, type);
         shoppingCart.Add(movie);
         SetSession(key, shoppingCart, type);
     }
     else
     {
         Movies = GetSession(key, type);
         Movies.Add(movie);
         SetSession(key, Movies, type);
     }
 }
示例#4
0
        public IActionResult AddToCart(RentMovie movie)
        {
            List <RentMovie> cartList;
            string           movieCartJSON = HttpContext.Session.GetString("Cart") ?? "FirstTimeDoingThis";

            if (movieCartJSON != "FirstTimeDoingThis")
            {
                cartList = JsonSerializer.Deserialize <List <RentMovie> >(movieCartJSON);
            }
            else
            {
                cartList = new List <RentMovie>();
            }

            bool isInCart = false;

            for (int i = 0; i < cartList.Count; i++)
            {
                if (cartList[i].ID == movie.ID)
                {
                    isInCart = true;
                    ViewData["Message result2"] = "Already in cart!";
                    break;
                }
            }

            if (isInCart == false)
            {
                isCartEmpty = false;
                cartList.Add(movie);

                ViewData["Receipt View"] = "Here is your receipt";
            }



            movieCartJSON = JsonSerializer.Serialize(cartList);

            HttpContext.Session.SetString("Cart", movieCartJSON);

            return(View(cartList));
        }
示例#5
0
        public IActionResult AddMovieToList()
        {
            //getting the new item from the Session
            RentMovie savedMovie = JsonSerializer.Deserialize <RentMovie>(HttpContext.Session.GetString("RentMovieSession"));
            //filling the saved list from our List session
            string movieListJSON = HttpContext.Session.GetString("MovieList") ?? "NOPE";

            if (movieListJSON != "NOPE")
            {
                savedMovies = JsonSerializer.Deserialize <List <RentMovie> >(movieListJSON);
            }
            //Adding the session  to the Saved List
            savedMovies.Add(savedMovie);
            //resave the List with the new item in it.
            string movieListJson = JsonSerializer.Serialize(savedMovies);

            HttpContext.Session.SetString("MovieList", movieListJson);

            return(RedirectToAction("ListMovies"));
        }
示例#6
0
        public IActionResult AddToCart(RentMovie movie)
        {
            AddMovieToSession(shoppingCartKey, movie, "shopping");

            return(RedirectToAction(""));
        }
示例#7
0
 public IActionResult Result(RentMovie a)
 {
     return(View(a));
 }
 public IActionResult AddMovie(RentMovie movie)
 {
     return(View(movie));
 }