Ejemplo n.º 1
0
        //Get MovieHall Data
        public MovieHall GetMovieHallData()
        {
            int MovieHallId = MovieHallIdSession();

            response = GlobalVariables.WebApiClient.GetAsync($"{Controller}/GetMovieHallData/{MovieHallId}").Result;
            MovieHall MovieHallData = response.Content.ReadAsAsync <MovieHall>().Result;

            return(MovieHallData);
        }
Ejemplo n.º 2
0
        public void AddMovieHall(int movieId, int nrOfSeats)
        {
            var movieHall = new MovieHall
            {
                MovieId   = movieId,
                NrOfSeats = nrOfSeats
            };

            movieHallContext.Add(movieHall);
        }
Ejemplo n.º 3
0
        public void GenerateMovieHalls()
        {
            MovieHall moviehall = new MovieHall();

            moviehall.MovieHallId   = 201;
            moviehall.HallId        = 11;
            moviehall.MovieId       = 101;
            moviehall.MovieDateTime = new DateTime(2012, 5, 16, 06, 30, 00);
            AddMovieHall(moviehall);
            moviehall.MovieHallId   = 202;
            moviehall.HallId        = 12;
            moviehall.MovieId       = 101;
            moviehall.MovieDateTime = new DateTime(2012, 5, 16, 08, 30, 00);
            AddMovieHall(moviehall);
            moviehall.MovieHallId   = 203;
            moviehall.HallId        = 13;
            moviehall.MovieId       = 101;
            moviehall.MovieDateTime = new DateTime(2012, 5, 16, 12, 30, 00);
            AddMovieHall(moviehall);
            moviehall.MovieHallId   = 204;
            moviehall.HallId        = 11;
            moviehall.MovieId       = 103;
            moviehall.MovieDateTime = new DateTime(2012, 5, 17, 06, 50, 00);
            AddMovieHall(moviehall);
            moviehall.MovieHallId   = 205;
            moviehall.HallId        = 12;
            moviehall.MovieId       = 103;
            moviehall.MovieDateTime = new DateTime(2012, 5, 17, 08, 30, 00);
            AddMovieHall(moviehall);
            moviehall.MovieHallId   = 206;
            moviehall.HallId        = 13;
            moviehall.MovieId       = 103;
            moviehall.MovieDateTime = new DateTime(2012, 5, 17, 12, 30, 00);
            AddMovieHall(moviehall);
            moviehall.MovieHallId   = 207;
            moviehall.HallId        = 11;
            moviehall.MovieId       = 104;
            moviehall.MovieDateTime = new DateTime(2012, 5, 16, 08, 30, 00);
            AddMovieHall(moviehall);
            moviehall.MovieHallId   = 208;
            moviehall.HallId        = 12;
            moviehall.MovieId       = 104;
            moviehall.MovieDateTime = new DateTime(2012, 5, 18, 10, 30, 00);
            AddMovieHall(moviehall);
            moviehall.MovieHallId   = 209;
            moviehall.HallId        = 13;
            moviehall.MovieId       = 104;
            moviehall.MovieDateTime = new DateTime(2012, 5, 17, 12, 30, 00);
            AddMovieHall(moviehall);
        }
Ejemplo n.º 4
0
        //添加影厅
        public string AddMovieHall(MovieHall hall, HttpPostedFileBase file)
        {
            hall.H_State = 1;//影厅状态默认为未使用1
            var name     = Server.MapPath("/MovieHallImg/");
            var fileName = DateTime.Now.ToString("yyyyMMddhhmmss") + file.FileName;

            file.SaveAs(name + fileName);
            hall.H_Photo = "/MovieHallImg/" + fileName;
            string str = JsonConvert.SerializeObject(hall);
            string i   = HttpClientHelper.SendRequest("api/Lmq/AddMovieHall", "post", str);

            if (i == "1")
            {
                return("<script>alert('添加成功');location.href='/LmqMVC/ShowMovieHall';</script>");
            }
            else
            {
                return("<script>alert('添加失败');location.href='/LmqMVC/ShowMovieHall';</script>");
            }
        }
Ejemplo n.º 5
0
        public ActionResult MovieSeats()
        {
            int UserDetailsId = UserIdSession();
            int MovieHallId   = MovieHallIdSession();

            //5 minutes for payment
            Session["PaymentId"] = UserDetailsId;
            Session.Timeout      = 5;

            response = GlobalVariables.WebApiClient.GetAsync($"{Controller}/GetMovieSeats/{MovieHallId}").Result;
            IEnumerable <MovieHallDetails> movieSeats = response.Content.ReadAsAsync <IEnumerable <MovieHallDetails> >().Result;

            //Get Current Hall Data
            Hall HallData = GetHallData();

            //Get Movie Data
            Movie MovieData = GetMovieData();

            //Get Current Movie Hall Data
            MovieHall MovieHallData = GetMovieHallData();

            //Get Current User Data
            UserDetails UserDetails = GetUserDetails();

            //Ticket Total Price
            double TicketTotal = GetTicketPrice();

            ViewBag.CurrentBalance   = UserDetails.Balance;
            ViewBag.RemainingBalance = UserDetails.Balance - TicketTotal;
            Session["BalanceCount"]  = UserDetails.Balance - TicketTotal;
            ViewBag.Username         = UserDetails.Name;
            ViewBag.HallNo           = HallData.HallNo;
            ViewBag.MovieId          = MovieData.MovieId;
            ViewBag.MovieTitle       = MovieData.MovieTitle;
            ViewBag.MovieDateTime    = MovieHallData.MovieDateTime.ToString("h:mm tt");
            ViewBag.TicketPrice      = MovieData.TicketPrice;
            ViewBag.UserDetailsId    = UserDetailsId;
            return(View(movieSeats));
        }
Ejemplo n.º 6
0
 public void AddMovieHall(MovieHall moviehall)
 {
     db.MovieHall.Add(moviehall);
     Save();
 }
Ejemplo n.º 7
0
 public bool UpdateMovieHall(MovieHall movieHall)
 {
     context.MovieHall.Update(movieHall);
     return(Save());
 }
Ejemplo n.º 8
0
 public bool DeleteMovieHall(MovieHall movieHall)
 {
     context.MovieHall.Remove(movieHall);
     return(Save());
 }
Ejemplo n.º 9
0
 public bool CreateMovieHall(MovieHall movieHall)
 {
     context.MovieHall.Add(movieHall);
     return(Save());
 }
Ejemplo n.º 10
0
        public ActionResult UpdateCart(string Seat)
        {
            AppDbContext db = new AppDbContext();

            int UserDetailsId = UserIdSession();
            int MovieId       = MovieSessionId();
            int MovieHallId   = MovieHallIdSession();

            //Replacing Empty / Taken Seat
            var replaceEmptyOrTakenSeat = db.MovieHallDetails.Where(d => d.Seat == Seat && d.MovieHallId == MovieHallId).SingleOrDefault();

            //Get Movie Data
            Movie MovieData = GetMovieData();

            //Get Current Hall Data
            Hall HallData = GetHallData();

            //Get Current Movie Hall Data
            MovieHall MovieHallData = GetMovieHallData();

            //Get Current User Data
            UserDetails UserDetails = GetUserDetails();

            //Ticket Total Price
            double TicketTotal = GetTicketPrice();

            //Calculate minimum balance needed for ticket
            if (TicketTotal + MovieData.TicketPrice > UserDetails.Balance && replaceEmptyOrTakenSeat.SeatStatus == Status.E)
            {
                return(Json(new { Button = true, Msg = UserDetails.Name + " , you need minimum RM" + (MovieData.TicketPrice - Convert.ToDouble(Session["BalanceCount"])) + " to buy seat " + "(" + Seat + ")" }, JsonRequestBehavior.AllowGet));
            }
            int mhdId = replaceEmptyOrTakenSeat.Id;

            if (replaceEmptyOrTakenSeat.UserDetailsId == null)
            {
                //Current Seat Id

                MovieHallDetails mhd = new MovieHallDetails
                {
                    Id            = mhdId,
                    MovieHallId   = MovieHallId,
                    Seat          = Seat,
                    SeatStatus    = Status.A,
                    UserDetailsId = UserDetailsId
                };

                response = GlobalVariables.WebApiClient.PutAsJsonAsync($"{MovieHallDetailsController}/{mhdId}", mhd).Result;

                UserCart cart = new UserCart()
                {
                    UserDetailsId = UserDetailsId,
                    MovieHallsId  = MovieHallId,
                    MovieTitle    = MovieData.MovieTitle,
                    MovieDateTime = MovieHallData.MovieDateTime,
                    HallNo        = HallData.HallNo,
                    TicketPrice   = MovieData.TicketPrice,
                    Seat          = Seat,
                    ConfirmCart   = false
                };

                response = GlobalVariables.WebApiClient.PostAsJsonAsync($"{UserCartController}", cart).Result;
                return(Json(JsonRequestBehavior.AllowGet));
            }
            else
            {
                var removeCart = db.UserCarts.Where(d => d.Seat == Seat && d.UserDetailsId == UserDetailsId && d.MovieHallsId == MovieHallId).SingleOrDefault();
                response = GlobalVariables.WebApiClient.DeleteAsync($"{UserCartController}/{removeCart.Id}").Result;

                MovieHallDetails mhd = new MovieHallDetails
                {
                    Id            = mhdId,
                    MovieHallId   = MovieHallId,
                    Seat          = Seat,
                    SeatStatus    = Status.E,
                    UserDetailsId = null
                };
                response = GlobalVariables.WebApiClient.PutAsJsonAsync($"{MovieHallDetailsController}/{mhdId}", mhd).Result;
                return(Json(JsonRequestBehavior.AllowGet));
            }
        }