public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Stake).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StakeExists(Stake.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } var emptyDog = new Dog(); if (await TryUpdateModelAsync <Dog>( emptyDog, "dog", s => s.RegisteredName, s => s.CallName, s => s.Sex, s => s.DateOfBirth, s => s.RegistrationNumber, s => s.Breed, s => s.OwnerID)) { _context.Dogs.Add(emptyDog); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } PopulatePersonNamesDropDownList(_context, emptyDog.Owner); return(Page()); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Stakes.Add(Stake); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Person = await _context.People.FindAsync(id); if (Person != null) { _context.People.Remove(Person); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Club = await _context.Clubs.FindAsync(id); if (Club != null) { _context.Clubs.Remove(Club); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }