public async Task <IActionResult> PutTableStudent(int id, TableStudent tableStudent) { if (id != tableStudent.StudentId) { return(BadRequest()); } _context.Entry(tableStudent).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TableStudentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult DeleteConfirmed(int id) { TableStudent tableStudent = db.TableStudents.Find(id); db.TableStudents.Remove(tableStudent); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Name,Email")] TableStudent tableStudent) { if (ModelState.IsValid) { db.Entry(tableStudent).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tableStudent)); }
public ActionResult Create([Bind(Include = "Id,Name,Email")] TableStudent tableStudent) { if (ModelState.IsValid) { db.TableStudents.Add(tableStudent); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tableStudent)); }
// GET: TableStudents/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TableStudent tableStudent = db.TableStudents.Find(id); if (tableStudent == null) { return(HttpNotFound()); } return(View(tableStudent)); }
public async Task <ActionResult <TableStudent> > PostTableStudent(TableStudent tableStudent) { _context.TableStudent.Add(tableStudent); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (TableStudentExists(tableStudent.StudentId)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetTableStudent", new { id = tableStudent.StudentId }, tableStudent)); }