public IActionResult DeleteStudent(int id) { _studentsRepo.Delete(id); _studentsRepo.SaveChanges(); return(Ok()); }
public IActionResult Delete(int id) { var emp = studentsRepository.Get(id); if (emp != null) { studentsRepository.Delete(emp.Id); return(RedirectToAction("Index")); } return(View()); }
public ActionResult Delete(Student student) { //save to db. if (ModelState.IsValid) { int id = student.StudentId; studentsRepository.Delete(id); return(RedirectToAction("Index")); } else { return(View(student)); } }
// GET: StudentsController/Delete/5 public async Task <ActionResult> DeleteAsync(int id) { try { var result = await _studentsRepository.Delete(id); TempData["SuccessResultF"] = result.Item1; TempData["SuccessResultM"] = result.Item2; return(RedirectToAction("Index", "Students")); } catch (Exception) { throw; } }
public async Task <IActionResult> Delete(int?id) { var deleteStudent = _studentsRepository.GetSingle(s => s.ID == id); if (deleteStudent == null) { return(new NotFoundResult()); } else { IEnumerable <Enrollment> enrollments = _enrollmentRepository.FindBy(e => e.StudentID == id); foreach (var enrollment in enrollments) { _enrollmentRepository.Delete(enrollment); } _studentsRepository.Delete(deleteStudent); await _studentsRepository.CommitAsync(); return(new NoContentResult()); } }
public int Delete(int id) { return(_studentsRepository.Delete(id)); }
public async Task Delete(int id) { await _studentsRepository.Delete(id); }
public async Task <bool> DeleteStudent(Guid id) { return(await _studentsRepository.Delete(id)); }
public IActionResult Index(int id) { repository.Delete(id); return(RedirectToAction("Index", "Students")); }
public void Delete(int id) { repository.Delete(id); }