// 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(Movie).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieExists(Movie.ID)) { return(NotFound()); } else { throw; } } 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()); } _context.Movie.Add(Movie); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task OnGetAsync(string sortOrder) { Movie = await _context.Movie.ToListAsync(); if (sortOrder == "StartTime") { Movie = Movie.OrderByDescending(s => s.StartTime).ThenByDescending(s => s.SeatsLeft).ToList(); } else if (sortOrder == "SeatsLeft") { Movie = Movie.OrderByDescending(s => s.SeatsLeft).ThenByDescending(s => s.StartTime).ToList(); } await _context.SaveChangesAsync(); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Movie = await _context.Movie.FindAsync(id); if (Movie != null) { _context.Movie.Remove(Movie); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }