// To protect from overposting attacks, 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(Track).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TrackExists(Track.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } var artist = await _context.Artists.FindAsync(id); if (artist == null) { return(NotFound()); } try { _context.Artists.Remove(artist); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } catch (DbUpdateException /*ex*/) { return(RedirectToAction("./Delete", new { id, saveChangesError = true })); } }
// To protect from overposting attacks, 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.Tracks.Add(Track); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Booking = await _context.Bookings.FindAsync(id); if (Booking != null) { _context.Bookings.Remove(Booking); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { var emptyEvent = new Event(); if (await TryUpdateModelAsync <Event>( emptyEvent, "event", //Prefix for form value. s => s.EventName, s => s.EventDate, s => s.Type)) { _context.Events.Add(Event); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } return(Page()); }
// To protect from overposting attacks, 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()); } try { _context.Bookings.Add(Booking); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } catch (Exception) { return(RedirectToAction("./Create", new { saveChangesError = true })); } }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { var emptyArtist = new Artist(); if (await TryUpdateModelAsync <Artist>( emptyArtist, "artist", //Prefix for form value. s => s.StageName)) { _context.Artists.Add(Artist); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } return(Page()); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync(int id) { var eventToUpdate = await _context.Events.FindAsync(id); if (eventToUpdate == null) { return(NotFound()); } if (await TryUpdateModelAsync <Event>( eventToUpdate, "event", s => s.EventName, s => s.EventDate, s => s.Type)) { await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } return(Page()); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync(int id) { var artistToUpdate = await _context.Artists.FindAsync(id); if (artistToUpdate == null) { return(NotFound()); } if (await TryUpdateModelAsync <Artist>( artistToUpdate, "artist", s => s.StageName)) { await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } return(Page()); }