public string Add(int Id)
        {
            var   db    = new MovieDatabaseDB();
            movie movie = db.getAMovie(Id);

            if (Session["cart"] == null)
            {
                List <movie> movies = new List <movie>();
                movies.Add(movie);
                Session["cart"]      = movies;
                ViewBag.cart         = movies.Count();
                Session["cartcount"] = 1;
            }
            else
            {
                List <movie> movies        = (List <movie>)Session["cart"];
                bool         containsMovie = movies.Any(i => i.id == Id);
                if (!containsMovie)
                {
                    movies.Add(movie);
                    Session["cart"]      = movies;
                    ViewBag.cart         = movies.Count();
                    Session["cartcount"] = Convert.ToInt32(Session["cartcount"]) + 1;
                }
            }
            var    jsonSerializer = new JavaScriptSerializer();
            string json           = jsonSerializer.Serialize("OK");

            return(json);
        }
 public ActionResult Buy()
 {
     if (Session["cart"] != null && Session["LoggedIn"] != null)
     {
         if (Session["LoggedIn"].ToString().Equals("true"))
         {
             var          db       = new MovieDatabaseDB();
             List <movie> movies   = (List <movie>)Session["cart"];
             List <Movie> Movies   = db.convertMovies(movies);
             var          Username = (Session["username"]).ToString();
             db.newOrder(Movies, Username);
             Session["cart"]      = null;
             Session["cartcount"] = null;
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             return(RedirectToAction("Login", "Security"));
         }
     }
     else
     {
         return(RedirectToAction("Login", "Security"));
     }
 }
Exemple #3
0
        public string getIfBought(int Id)
        {
            var db = new MovieDatabaseDB();

            if (Session["username"] != null)
            {
                var    username = Session["username"].ToString();
                string bought   = "";
                if (db.checkIfBought(Id, username))
                {
                    bought = "YES";
                }
                else
                {
                    bought = "NO";
                }
                var    jsonSerializer = new JavaScriptSerializer();
                string json           = jsonSerializer.Serialize(bought);
                return(json);
            }
            else
            {
                var    jsonSerializer = new JavaScriptSerializer();
                string json           = jsonSerializer.Serialize("NO");
                return(json);
            }
        }
Exemple #4
0
        public JsonResult getMoviesFromGenre(int id)
        {
            var db = new MovieDatabaseDB();
            List <imageMovie> allMovies = db.getMoviesFromGenre(id);
            JsonResult        ut        = Json(allMovies, JsonRequestBehavior.AllowGet);

            return(ut);
        }
Exemple #5
0
        public JsonResult getAllGenresController()
        {
            var          db        = new MovieDatabaseDB();
            List <genre> allGenres = db.getAllGenres();
            JsonResult   ut        = Json(allGenres, JsonRequestBehavior.AllowGet);

            return(ut);
        }
Exemple #6
0
        /*public string getAllMovieURLs()
         * {
         *  var db = new MovieDatabaseDB();
         *  List<movie> allMovies = db.getAllMovies();
         *  var allURLs = new List<imageMovie>();
         *  foreach (movie k in allMovies)
         *  {
         *      var movieURL = new imageMovie();
         *      movieURL.id = k.id;
         *      movieURL.imageURL = k.imageURL;
         *      allURLs.Add(movieURL);
         *  }
         *  var jsonSerializer = new JavaScriptSerializer();
         *  string json = jsonSerializer.Serialize(allURLs);
         *  return json;
         * }*/
        public string getMovieInfo(int Id)
        {
            var    db             = new MovieDatabaseDB();
            movie  aMovie         = db.getAMovie(Id);
            var    jsonSerializer = new JavaScriptSerializer();
            string json           = jsonSerializer.Serialize(aMovie);

            return(json);
        }
        public string getCartCount()
        {
            var db             = new MovieDatabaseDB();
            var jsonSerializer = new JavaScriptSerializer();

            if (Session["cartcount"] != null)
            {
                var cartcount = Convert.ToInt32(Session["cartcount"]);
                return(jsonSerializer.Serialize(cartcount));
            }
            else
            {
                return(jsonSerializer.Serialize(0));
            }
        }
        public string isLoggedIn()
        {
            var db             = new MovieDatabaseDB();
            var jsonSerializer = new JavaScriptSerializer();

            if (Session["LoggedIn"] != null)
            {
                var loggedin = Session["LoggedIn"].ToString();
                if (db.isLoggedInModel(loggedin))
                {
                    return(jsonSerializer.Serialize("YES"));
                }
                else
                {
                    return(jsonSerializer.Serialize("NO"));
                }
            }
            return(jsonSerializer.Serialize("NO"));
        }