public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { Specialtys = new SelectList(await _context.Specialtys.ToListAsync(), "Id", "Name"); return(Page()); } _context.Attach(Student).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudentExists(Student.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Specialty).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SpecialtyExists(Specialty.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Specialtys.Add(Specialty); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Specialty = await _context.Specialtys.FindAsync(id); if (Specialty != null) { _context.Specialtys.Remove(Specialty); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }