Ejemplo n.º 1
0
        public ActionResult AddShow(int hallId, string MovieName, DateTime time = default)
        {
            if (hallId == 0 || MovieName == "0" || time == null)
            {
                string msg = "You need to fill the details of the new show";
                return(RedirectToAction("AddShow", "Admin", new { msg }));
            }

            if (time < DateTime.Now.AddDays(1))
            {
                string msg = "Adding show time need to be 24 Hour before show!!";
                return(RedirectToAction("AddShow", "Admin", new { msg }));
            }
            ShowDal sd = new ShowDal();

            sd.GetAllHallShow(hallId);
            foreach (Show s in sd.MyList)
            {
                Movie m = new Movie();
                m.GetMovieById(s.movie);

                if (Math.Abs(s.dateTime.Subtract(time).TotalMinutes) < m.MovieLength + 30)
                {
                    string msg = "Invalid Date Or Time";
                    return(RedirectToAction("AddShow", "Admin", new { msg }));
                }
            }
            Show show = new Show
            {
                hall     = hallId,
                movie    = Movie.GetIdByName(MovieName),
                dateTime = time
            };

            show.AddToDb();

            return(RedirectToAction("AdminHomePage", "Admin"));
        }