// 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 holeToUpdate = await _context.Holes.FindAsync(id); if (holeToUpdate == null) { return(NotFound()); } try { if (await TryUpdateModelAsync <Hole>(holeToUpdate, "hole", h => h.Par, h => h.Num, h => h.CourseId)) { await _context.SaveChangesAsync(); return(RedirectToPage("./IndexHole")); } } catch (DbUpdateConcurrencyException) { if (!HoleExists(Hole.HoleId)) { return(NotFound()); } else { throw; } } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Hole = await _context.Holes.FindAsync(id); if (Hole == null) { return(NotFound()); } try { _context.Holes.Remove(Hole); await _context.SaveChangesAsync(); return(RedirectToPage("./IndexHole")); } catch (DbUpdateException ex) { return(RedirectToAction("./DeleteHole", 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.Attach(Round).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoundExists(Round.RoundId)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./IndexRound")); }
// 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()); } var emptyCourse = new Course(); //var holeToUpdate = await _context.Hole.FindAsync(HoleId); //if (await TryUpdateModelAsync<Hole>(holeToUpdate, "hole", h=> h.CourseId)) if (await TryUpdateModelAsync <Course>(emptyCourse, "course", c => c.Name, c => c.Par, c => c.LocationId, c => c.DateFounded, c => c.Type)) { _context.Courses.Add(Course); await _context.SaveChangesAsync(); return(RedirectToPage("./IndexCourse")); } //_context.Course.Add(Course); //await _context.SaveChangesAsync(); return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } var courseToDelete = await _context.Courses.Where(c => c.CourseId == id).Include(c => c.Holes).ToListAsync(); if (courseToDelete == null) { return(NotFound()); } try { _context.Courses.Remove(courseToDelete.FirstOrDefault()); await _context.SaveChangesAsync(); return(RedirectToPage("./IndexCourse")); } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log.) return(RedirectToAction("./DeleteCourse", 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.Golfers.Add(Golfer); await _context.SaveChangesAsync(); return(RedirectToPage("./IndexGolfer")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Golfer = await _context.Golfers.FindAsync(id); if (Golfer != null) { _context.Golfers.Remove(Golfer); await _context.SaveChangesAsync(); } return(RedirectToPage("./IndexGolfer")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Location = await _context.Locations.FindAsync(id); if (Location != null) { _context.Locations.Remove(Location); await _context.SaveChangesAsync(); } return(RedirectToPage("./IndexLocation")); }
// 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()); } var emptyHole = new Hole(); if (await TryUpdateModelAsync <Hole>(emptyHole, "hole", h => h.Par, h => h.CourseId, h => h.Num)) { _context.Holes.Add(emptyHole); await _context.SaveChangesAsync(); } return(RedirectToPage("./IndexHole")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Round = await _context.Rounds.FindAsync(id); if (Round != null) { _context.Rounds.Remove(Round); await _context.SaveChangesAsync(); } return(RedirectToPage("./IndexRound")); }
// 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) { if (!ModelState.IsValid) { return(Page()); } var courseToUpdate = await _context.Courses.FindAsync(id); if (courseToUpdate == null) { return(NotFound()); } try { if (await TryUpdateModelAsync <Course>(courseToUpdate, "course", c => c.Name, c => c.Par, c => c.LocationId, c => c.DateFounded, c => c.Type)) { await _context.SaveChangesAsync(); return(RedirectToPage("./IndexCourse")); } } catch (DbUpdateConcurrencyException) { if (!CourseExists(Course.CourseId)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./IndexCourse")); }