// To protect from overposting attacks, please 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.Seances.Add(Seance); await _context.SaveChangesAsync(); Etudiants = await _context.Utilisateurs.Where(s => s.ClasseId == Seance.ClasseId).ToListAsync(); Absence abs; foreach (var item in Etudiants) { abs = new Absence(); abs.EtudiantId = item.Id; abs.SeanceId = Seance.Id; abs.statut = true; _context.Absences.Add(abs); } await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
// To protect from overposting attacks, please 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(Classe).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClasseExists(Classe.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, please 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.Classes.Add(Classe); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Seance = await _context.Seances.FindAsync(id); if (Seance != null) { _context.Seances.Remove(Seance); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }