Exemple #1
0
        //Show Get
        public IActionResult Show(int Id)
        {
            var obj = _db.ScreeningRoom.Find(Id);

            if (obj == null)
            {
                return(NotFound());
            }

            List <Seat>         seats       = _db.Seat.Where(s => s.IdScreeningRoom == obj.Id).ToList();
            List <List <Seat> > listOfSeats = new List <List <Seat> >();

            for (int i = 0; i < obj.NumberOfRows; i++)
            {
                List <Seat> tempList = new List <Seat>();
                for (int j = 0; j < obj.NumberOfSeatsPerRow; j++)
                {
                    tempList.Add(seats[j + i * obj.NumberOfSeatsPerRow]);
                }
                listOfSeats.Add(tempList);
            }

            SeatVM seatVM = new SeatVM()
            {
                IdCinema = (int)obj.IdCinema, Seats = listOfSeats
            };

            return(View(seatVM));
        }
Exemple #2
0
        public IActionResult Create(int Id)
        {
            ScreeningRoom       screeningRoom = _db.ScreeningRoom.Find(Id);
            List <List <Seat> > seats         = new List <List <Seat> >();

            for (int i = 0; i < screeningRoom.NumberOfRows; i++)
            {
                List <Seat> tempList = new List <Seat>();
                for (int j = 0; j < screeningRoom.NumberOfSeatsPerRow; j++)
                {
                    tempList.Add(new Seat()
                    {
                        RowNumber       = i,
                        SeatNumber      = j,
                        IdScreeningRoom = Id,
                        IsValid         = true
                    });
                }
                seats.Add(tempList);
            }

            SeatVM obj = new SeatVM()
            {
                IdCinema = (int)screeningRoom.IdCinema, Seats = seats
            };

            return(View(obj));
        }
        public IHttpActionResult PostSeat(SeatVM vm)
        {
            var userId = User.Identity.GetUserId();

            if (_unit.User.IsAdmin(userId))
            {
                int seatId = _unit.Admin.PostSeat(vm);

                if (vm.Id == 0)
                {
                    //create new user
                    RegisterBindingModel rbm = new RegisterBindingModel
                    {
                        Email    = seatId.ToString() + "@gmail.com",
                        Password = "******"
                    };

                    var user = new ApplicationUser()
                    {
                        UserName = rbm.Email,
                        Email    = rbm.Email
                    };

                    IdentityResult result = UserManager.Create(user, rbm.Password);

                    //set new user SeatInfo
                    _unit.Admin.AttachSeatToUser(seatId);
                }

                return(Ok());
            }
            return(Unauthorized());
        }
Exemple #4
0
        public IActionResult Create(SeatVM seatVM)
        {
            foreach (var row in seatVM.Seats)
            {
                foreach (var seat in row)
                {
                    _db.Add(seat);
                    _db.SaveChanges();
                }
            }

            return(RedirectToAction("Index", "ScreeningRoom", new { id = seatVM.IdCinema }));
        }
        public int PostSeat(SeatVM vm)
        {
            SeatInfo seat = null;

            if (vm.Id > 0)
            {
                seat = _db.SeatInfos.Where(s => s.Id == vm.Id).FirstOrDefault();

                if (vm.Section != null)
                {
                    seat.Section = vm.Section;
                }
                if (vm.Row != null)
                {
                    seat.Row = vm.Row;
                }
                if (vm.Chair != null)
                {
                    seat.Chair = vm.Chair;
                }
                if (vm.IsRetired)
                {
                    seat.IsRetired = vm.IsRetired;
                }
            }
            else if (vm.AreaId > 0)
            {
                seat = new SeatInfo
                {
                    AreaId  = vm.AreaId,
                    Section = vm.Section,
                    Row     = vm.Row,
                    Chair   = vm.Chair
                };

                _db.SeatInfos.Add(seat);
            }

            _db.SaveChanges();

            return(seat.Id);
        }
Exemple #6
0
        // GET: Reservation


        public ActionResult Seat(int movieID, int saloonID, int sessionID)
        {
            Session ses = _sesRep.FirstOrDefault(x => x.ID == sessionID);

            if (DateTime.Now <= ses.Time && DateTime.Now.AddMinutes(30) >= ses.Time)
            {
                List <Sale> list = _saleRep.Where(x => x.SaleType == ENTITIES.Enums.SaleType.Reservation && x.SessionID == sessionID);
                List <int>  toBeUpdatedSeatsId;
                for (int i = 0; i < list.Count; i++)
                {
                    int saleId = list[i].ID;
                    toBeUpdatedSeatsId = _saleSeatRep.Where(x => x.SaleID == saleId).Select(x => x.SeatID).ToList();
                    foreach (int id in toBeUpdatedSeatsId)
                    {
                        Seat seat = _sRep.FirstOrDefault(x => x.ID == id);
                        seat.SeatActive = false;
                        _sRep.Update(seat);
                    }
                    _saleSeatRep.DeleteRange(_saleSeatRep.Where(x => x.SaleID == saleId));
                    _saleRep.Delete(list[i]);
                }
            }

            Session     selectedSession = _sesRep.Find(sessionID);
            List <Seat> seats           = _sRep.Where(x => x.SessionID == sessionID && x.SaloonID == saloonID);
            SeatVM      svm             = new SeatVM
            {
                //Tum koltuklari cek.
                Seats = seats,
                Price = selectedSession.Price
            };

            TempData["movieID"]     = movieID;
            TempData["saloonID"]    = saloonID;
            TempData["sessionID"]   = sessionID;
            TempData["sessionTime"] = ses.Time;



            return(View(svm));
        }