public async Task OnGetAsync() { // //Allocate = await _context.Allocate_1.ToListAsync(); // Allocate = await _context.Allocate_1 //.Include(c => c.Volunteer) //.AsNoTracking() ////.ToListAsync(); //Allocate = await _context.Allocate_1 // .Include(c => c.Volunteer.Firstname) // .Include(c => c.Volunteer.Lastname) // .AsNoTracking() // .ToListAsync(); await _context.SaveChangesAsync(); AllocateVM = await _context.Volunteer .Select(p => new AllocateViewModel { AllocateID = p.VolunteerID, Firstname = p.Firstname, Lastname = p.Lastname, }) .Include(p => p.IsAllocate) .ToListAsync(); async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Allocate).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AllocateExists(Allocate.AllocateID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); } bool AllocateExists(int id) { return(_context.Allocate_1.Any(e => e.AllocateID == id)); } }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Allocate).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AllocateExists(Allocate.AllocateID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Event.Add(Event); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Allocate = await _context.Allocate_1.FindAsync(id); if (Allocate != null) { _context.Allocate_1.Remove(Allocate); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Volunteer = await _context.Volunteer.FindAsync(id); if (Volunteer != null) { _context.Volunteer.Remove(Volunteer); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Event = await _context.Event.FindAsync(id); if (Event != null) { _context.Event.Remove(Event); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }