Ejemplo n.º 1
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Theater).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TheaterExists(Theater.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync(string[] selectedSeats)
        {
            foreach (var i in Tickets)
            {
                foreach (string seat in selectedSeats)
                {
                    if (Tickets.Where(t => t.Seat == seat) != null)
                    {
                        selectedSeats = selectedSeats.Where(s => s != seat).ToArray();
                        break;
                    }
                }
            }

            if (!String.IsNullOrEmpty(UserId))
            {
                var user = await _userManager.FindByIdAsync(UserId);

                if (user == null)
                {
                    return(RedirectToPage("./Buyticket", new { ShowtimeID = Ticket.ShowtimeID, Error = true }));
                }
                else
                {
                    UserId = user.Id;
                }
            }

            var money = 95000;

            if (Ticket.Showtime.Format == "3D")
            {
                money = 125000;
            }
            else if (Ticket.Showtime.Format == "4DX")
            {
                money = 150000;
            }

            var staff = await _userManager.GetUserAsync(User);

            foreach (string seat in selectedSeats)
            {
                Ticket TempTicket = new Ticket()
                {
                    ShowtimeID = Ticket.ShowtimeID,
                    Seat       = seat,
                    UserID     = UserId,
                    StaffID    = staff.Id,
                    Got        = true,
                    Money      = money
                };
                _context.Tickets.Add(TempTicket);
            }
            await _context.SaveChangesAsync();

            return(RedirectToPage("../Index"));
        }
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var showtimes = (from s in _context.Showtimes
                             .Include(s => s.Movie)
                             .Include(s => s.Theater)
                             where s.StartTime.Date == Showtime.StartTime.Date &&
                             s.TheaterID == Showtime.TheaterID
                             select s).ToList();

            Showtime.Movie = (from m in _context.Movies
                              where m.ID == Showtime.MovieID
                              select m).First();

            foreach (Showtime st in showtimes)
            {
                if (DateTime.Compare(st.StartTime, Showtime.StartTime) < 0)
                {
                    if (DateTime.Compare(st.StartTime.AddMinutes(st.Movie.Duration).AddMinutes(15), Showtime.StartTime) >= 0)
                    {
                        return(RedirectToPage("./Create", new { Error = 1 }));
                    }
                }
                else if (DateTime.Compare(st.StartTime, Showtime.StartTime) == 0)
                {
                    return(RedirectToPage("./Create", new { Error = 1 }));
                }
                else if (DateTime.Compare(st.StartTime, Showtime.StartTime) > 0)
                {
                    if (DateTime.Compare(Showtime.StartTime.AddMinutes(Showtime.Movie.Duration).AddMinutes(15), st.StartTime) >= 0)
                    {
                        return(RedirectToPage("./Create", new { Error = 1 }));
                    }
                }
            }

            var theater = (from t in _context.Theaters
                           where t.ID == Showtime.TheaterID
                           select t).First();

            if ((theater.Format == "4DX" && Showtime.Format != "4DX") || (theater.Format == "2D" && Showtime.Format != "2D") || (theater.Format == "3D" && Showtime.Format == "4DX"))
            {
                return(RedirectToPage("./Create", new { Error = 2 }));
            }

            _context.Showtimes.Add(Showtime);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Manage"));
        }
Ejemplo n.º 4
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Theaters.Add(Theater);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Movie = await _context.Movies.FindAsync(id);

            if (Movie != null)
            {
                _context.Movies.Remove(Movie);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync(string[] selectedSeats)
        {
            foreach (var i in Tickets)
            {
                foreach (string seat in selectedSeats)
                {
                    if (Tickets.Where(t => t.Seat == seat) != null)
                    {
                        selectedSeats = selectedSeats.Where(s => s != seat).ToArray();
                        break;
                    }
                }
            }

            var money = 95000;

            if (Ticket.Showtime.Format == "3D")
            {
                money = 125000;
            }
            else if (Ticket.Showtime.Format == "4DX")
            {
                money = 150000;
            }

            var user = await _userManager.GetUserAsync(User);

            var Code = RandomString();

            foreach (string seat in selectedSeats)
            {
                Ticket emptyTicket = new Ticket()
                {
                    ShowtimeID = Ticket.ShowtimeID,
                    Seat       = seat,
                    UserID     = user.Id,
                    CodeToGet  = Code,
                    Got        = false,
                    Money      = money
                };
                _context.Tickets.Add(emptyTicket);
            }
            await _context.SaveChangesAsync();

            return(RedirectToPage("../Movies/Index"));
        }
Ejemplo n.º 7
0
        //[BindProperty]
        // public IFormFile poster { get; set; }
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync(IFormFile poster)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var path   = Path.Combine(_environment.WebRootPath, "Picture", poster.FileName);
            var stream = new FileStream(path, FileMode.Create);
            await poster.CopyToAsync(stream);

            Movie.Poster = poster.FileName;

            _context.Movies.Add(Movie);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Manage"));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var ticket = await _context.Tickets.FirstOrDefaultAsync(m => m.ID == id);

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

            var staff = await _userManager.GetUserAsync(User);

            ticket.Got     = true;
            ticket.StaffID = staff.Id;

            await _context.SaveChangesAsync();

            return(RedirectToPage("./ListOfTickets"));
        }
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync(IFormFile poster)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (poster != null)
            {
                var path   = Path.Combine(_environment.WebRootPath, "Picture", poster.FileName);
                var stream = new FileStream(path, FileMode.Create);
                await poster.CopyToAsync(stream);

                Movie.Poster = poster.FileName;
            }

            _context.Attach(Movie).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MovieExists(Movie.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Manage"));
        }