// 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.Student.Add(Student); try { await _context.SaveChangesAsync(); } catch (DbUpdateException se) { if (se.InnerException.Message.Contains("IX_Student_NrMatricol")) { this.ModelState.AddModelError("", "Numarul matricol trebuie sa fie unic"); return(OnGet()); } throw; } 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() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Nota).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NotaExists(Nota.ID)) { return(NotFound()); } else { throw; } } 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() { if (!ModelState.IsValid) { return(Page()); } _context.Disciplina.Add(Disciplina); try { await _context.SaveChangesAsync(); } catch (DbUpdateException se) { if (se.InnerException.Message.Contains("IX_Disciplina_Nume")) { this.ModelState.AddModelError("", "Numele disciplinei trebuie sa fie unic"); return(OnGet()); } throw; } 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() { if (!ModelState.IsValid) { return(Page()); } _context.Nota.Add(Nota); try { await _context.SaveChangesAsync(); } catch (DbUpdateException se) { if (se.InnerException.Message.Contains("IX_Nota_StudentID_DisciplinaID")) { this.ModelState.AddModelError("", "Nota la aceasta materie exista deja"); return(OnGet()); } throw; } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Disciplina = await _context.Disciplina.FindAsync(id); if (Disciplina != null) { _context.Disciplina.Remove(Disciplina); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Student = await _context.Student.FindAsync(id); if (Student != null) { _context.Student.Remove(Student); 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() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Disciplina).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DisciplinaExists(Disciplina.ID)) { return(NotFound()); } else { throw; } } catch (DbUpdateException se) { if (se.InnerException.Message.Contains("IX_Disciplina_Nume")) { this.ModelState.AddModelError("", "Numele disciplinei trebuie sa fie unic"); return(await OnGetAsync(Disciplina.ID)); } throw; } return(RedirectToPage("./Index")); }