public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(RedirectToPage("AddBooking", FilmSchedule)); } if (Input.NumOfTickets > 12) { return(RedirectToPage("AddBooking", FilmSchedule)); } FilmSchedule filmschedule = await _db.FilmSchedule.FindAsync(FilmSchedule.Id); filmschedule.FreeChairs -= Input.NumOfTickets; Booking booking = new Booking { FilmScheduleId = this.FilmSchedule.Id, Name = Input.Name, PhoneNumber = Input.PhoneNumber, NumOfTickets = Input.NumOfTickets }; _db.Booking.Add(booking); await _db.SaveChangesAsync(); return(RedirectToPage("BookingConfirmation", booking)); }
public async Task OnGetAsync(int id) { FilmSchedule = await _db.FilmSchedule .Include(fs => fs.Film) .Include(fs => fs.Salon) .FirstOrDefaultAsync(fs => fs.Id == id); }