Esempio n. 1
0
        public ActionResult AddMovie(Movie movie)
        {
            MoviesDal dal          = new MoviesDal();
            HallsDal  hallDal      = new HallsDal();
            Hall      hall         = new Hall();
            var       sameHallname = dal.Movies.Any(x => x.Date == movie.Date && x.HallName == movie.HallName);
            var       HallName     = hallDal.Halls.Any(x => x.HallName == movie.HallName);
            var       sameDate     = dal.Movies.Any(x => x.Date == movie.Date);

            if (ModelState.IsValid)
            {
                if (sameDate == true)
                {
                    if (sameHallname == true)
                    {
                        TempData["MovieStatus"] = "There is a movie at the same date and hall.";
                        return(RedirectToAction("AddMovie", movie));
                    }
                    else
                    {
                        if (HallName == false)
                        {
                            hall.HallName  = movie.HallName;
                            hall.ColNumber = 10;
                            hall.RowNumber = 10;
                            hallDal.Halls.Add(hall);
                            hallDal.SaveChanges();
                        }
                        dal.Movies.Add(movie);
                        dal.SaveChanges();
                    }
                }
                else
                {
                    if (HallName == false)
                    {
                        hall.HallName  = movie.HallName;
                        hall.ColNumber = 10;
                        hall.RowNumber = 10;
                        hallDal.Halls.Add(hall);
                        hallDal.SaveChanges();
                    }
                    dal.Movies.Add(movie);
                    dal.SaveChanges();
                }
                return(RedirectToAction("MyPage", "Home"));
            }
            return(View("AddMovie", movie));
        }
        public ActionResult Edit(Hall hall)
        {
            HallsDal dal     = new HallsDal();
            Hall     objHall = (from x in dal.Halls
                                where x.HallName == hall.HallName
                                select x).Single <Hall>();

            dal.Halls.Remove(objHall);
            dal.Halls.Add(hall);
            dal.SaveChanges();
            return(RedirectToAction("MyPage", "Home"));
        }
Esempio n. 3
0
        public ActionResult Edit(MovieViewModel movie)
        {
            MoviesDal dal      = new MoviesDal();
            HallsDal  hallDal  = new HallsDal();
            Hall      hall     = new Hall();
            var       HallName = hallDal.Halls.Any(x => x.HallName == movie.movieName.HallName);
            Movie     objMovie = (from x in dal.Movies
                                  where x.MovieName == movie.movieName.MovieName
                                  select x).Single <Movie>();

            if (HallName == false)
            {
                hall.HallName  = movie.movieName.HallName;
                hall.ColNumber = 10;
                hall.RowNumber = 10;
                hallDal.Halls.Add(hall);
                hallDal.SaveChanges();
            }
            dal.Movies.Remove(objMovie);
            dal.Movies.Add(movie.movieName);
            dal.SaveChanges();
            return(RedirectToAction("EditMovie"));
        }