예제 #1
0
        public async Task <IActionResult> Create([Bind("ID,Name,MaxSeats")] Salon salon)
        {
            if (ModelState.IsValid)
            {
                _context.Add(salon);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(salon));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("ID,MovieID,SalonID,Date")] Showing showing)
        {
            if (ModelState.IsValid)
            {
                _context.Add(showing);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MovieID"] = new SelectList(_context.Movies, "ID", "Title", showing.MovieID);
            ViewData["SalonID"] = new SelectList(_context.Salons, "ID", "Name", showing.SalonID);
            return(View(showing));
        }
예제 #3
0
        public async Task <IActionResult> Thanks(int?id, int seatsInput)
        {
            var movie = _context.Conjunction
                        .Where(c => c.Id == id)
                        .Include(m => m.Movie);

            foreach (var i in movie)
            {
                i.Movie.SeatsNr -= seatsInput;
            }

            var context = _context.Conjunction
                          .Where(c => c.Id == id)
                          .Include(m => m.Movie)
                          .Include(r => r.Room);

            foreach (var i in context)
            {
                tempmovie   = i.Movie;
                tempRoom    = i.Room;
                temptstatus = i.Status;
            }

            ticket = new BookingTicket()
            {
                Movie       = tempmovie,
                Room        = tempRoom,
                BookingDate = DateTime.Now
            };

            _context.Add(ticket);
            await _context.SaveChangesAsync();

            var view = _context.BookingTickets
                       .Include(t => t.Movie)
                       .Include(t => t.Room).OrderByDescending(t => t.Id).ToList();

            return(View(view));
        }