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 = "Сталася невідома помилка при видаленні курсу!" }));
            }
        }
예제 #3
0
        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"));
        }
예제 #5
0
        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,
            });
        }
예제 #7
0
 public void Delete(Cours cours)
 {
     _CoursesRepo.Delete(cours);
     unitOfWork.Commit();
 }