public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Location).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LocationExists(Location.MovieID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (!ModelState.IsValid) { return(Page()); } var movieToUpdate = await _context.Movies .Include(l => l.Location) .Include(a => a.Appeareances) .ThenInclude(a => a.Actor) .FirstOrDefaultAsync(m => m.ID == id); if (await TryUpdateModelAsync <Movie>( movieToUpdate, "Movie", i => i.Title, i => i.ReleaseDate, i => i.Price, i => i.Genre, i => i.Location)) { if (String.IsNullOrWhiteSpace(movieToUpdate.Location?.Name)) { movieToUpdate.Location = null; } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieExists(Movie.ID)) { return(NotFound()); } else { throw; } } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Location.Add(Location); 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(int?id) { if (id == null) { return(NotFound()); } Location = await _context.Location.FindAsync(id); if (Location != null) { _context.Location.Remove(Location); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(string id) { if (id == null) { return(NotFound()); } ApplicationUser = await _context.Users.FindAsync(id); if (ApplicationUser != null) { _context.Users.Remove(ApplicationUser); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }