예제 #1
0
        public ActionResult CreateNewRentals(Rental RentalValus)
        {
            bool   TrueOrFalseMassege = true;
            string RentalMessges      = "Movie rental successfully added";

            if (ModelState.IsValid)
            {
                bool RentalCustomerExsit = CustomerTableHelper.CustomerExsit(RentalValus.CostomerName);
                bool RentalMovieExsit    = MoviesTableHelper.MovieExsit(RentalValus.MovieName);
                bool IsTheFilmRented     = RentalsTableHelper.IsTheFilmRented(RentalValus.MovieName);

                if (RentalCustomerExsit)
                {
                    if (RentalMovieExsit)
                    {
                        if (IsTheFilmRented)
                        {
                            TrueOrFalseMassege = false;
                            RentalMessges      = "The film is rented";
                        }
                        else
                        {
                            RentalsTableHelper.AddRentals(RentalValus.CostomerName, RentalValus.MovieName);
                            TrueOrFalseMassege = true;
                            RentalMessges      = "Movie rental successfully added";
                        }
                    }
                    else
                    {
                        TrueOrFalseMassege = false;
                        RentalMessges      = "Movie not Exsit";
                    }
                }
                else
                {
                    TrueOrFalseMassege = false;
                    RentalMessges      = "Customer not Exsit";
                    if (RentalMovieExsit != true)
                    {
                        RentalMessges += " Movie not found";
                    }
                }
            }
            else
            {
                TrueOrFalseMassege = false;
                ViewBag.succass    = "succass";
                RentalMessges      = "Movie rental successfully added";
            }
            var obj = new { RentalMessge = RentalMessges, MassegeBool = TrueOrFalseMassege };

            return(Json(obj, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult MoviesSave(Movie MoviesValus)
        {
            // Boolean variable that holds the result if the movie exists or not
            // המשתנה מקבל ניימספייס של קלאס בו בנוייה הפונקציה שמקבלת שם של סרט ומחזירה תוצאה בערך בוליאני
            bool MovieExsitValid = MoviesTableHelper.MovieExsit(MoviesValus.MovieName);

            ViewBag.MovieClass    = "";
            ViewBag.CategoryClass = "";

            if (ModelState.IsValid)
            {
                if (MovieExsitValid)
                {
                    ViewBag.messageExsit = "The Movie Name Inputs Exsit";
                    ViewBag.MovieClass   = "notvalid";
                    return(View("MoviesNew", MoviesValus));
                }
                else
                {
                    MoviesTableHelper.AddMovie(MoviesValus.MovieName, MoviesValus.MovieCategory);
                    return(RedirectToAction("MoviesIndex"));
                }
            }
            else
            {
                if (MoviesValus.MovieName == null)
                {
                    ViewBag.MovieClass = "notvalid";
                }
                if (MoviesValus.MovieCategory == null)
                {
                    ViewBag.CategoryClass = "notvalid";
                }
                return(View("MoviesNew", MoviesValus));
            }
        }