public async Task <IActionResult> Delete(int?id) { var deleteCourse = _coursesRepository.GetSingle(c => c.CourseID == id, c => c.Department); if (deleteCourse == null) { return(NotFound()); } _coursesRepository.Delete(deleteCourse); await _coursesRepository.CommitAsync(); return(NoContent()); }
public async Task <IActionResult> Delete(int courseId) { bool res = await _coursesRepository.Delete(courseId); if (res) { return(RedirectToAction("Index", "Courses", new { message = "Курс успішно видалений!" })); } else { return(RedirectToAction("Index", "Courses", new { error = "Сталася невідома помилка при видаленні курсу!" })); } }
public async Task <IActionResult> Delete(CoursesInformation coursesInformation) { try { var course = await _repository.Delete(coursesInformation.Id); return(Ok(course)); } catch (Exception) { throw; } }
// THis method is used to delete a course public IActionResult DeleteCourse(int id) { var course = _coursesRepository.FindById(id); if (course != null) { var deleted = _coursesRepository.Delete(course); if (deleted) { return(RedirectToAction("CourseList")); } return(View("Error", "Home")); } return(View("Error", "Home")); }
public IActionResult Delete(int id) { if (id <= 0) { return(BadRequest()); } var record = _coursesRepository.GetById(id); if (record == null) { return(NotFound()); } _coursesRepository.Delete(record); return(Ok()); }
public IResult <CourseDetails> Delete(Guid id) { if (id == Guid.Empty) { return(new Result <CourseDetails>().AddErrorMessage("Course id is empty")); } var result = _coursesRepository.Delete(id); if (result.Succeed) { _coursesRepository.UnitOfWork.SaveChanges(); } return(new Result <CourseDetails> { Return = new CourseDetails(result.Return), Messages = result.Messages, }); }
public void Delete(Cours cours) { _CoursesRepo.Delete(cours); unitOfWork.Commit(); }