public async Task <IActionResult> Delete([FromForm] SectionViewModel model)
        {
            var section = await repo.GetSectionAsync(model.Id);

            repo.DeleteSection(section);
            await repo.SaveAsync();

            return(RedirectToAction("Index"));
        }
Example #2
0
        public ActionResult <Section> DeleteSection(int id)
        {
            var sc = _sectionRepo.DeleteSection(id);

            if (sc == null)
            {
                return(NotFound());
            }
            return(sc);
        }
Example #3
0
        public void Restore(string json)
        {
            var sections = JsonConvert.DeserializeObject <IEnumerable <Section> >(json);

            foreach (var section in repo.GetAllSections())
            {
                repo.DeleteSection(section);
            }

            repo.Save();


            foreach (var section in sections)
            {
                repo.AddSection(section);
            }

            repo.Save();
        }
        public async Task <IActionResult> DeleteSection(int Section_Id)
        {
            if (ModelState.IsValid)
            {
                int result = await _SectionRepository.DeleteSection(Section_Id);

                if (result == 1)
                {
                    TempData["Success"] = "Section Deleted Successfully";
                    return(RedirectToAction("Index", "section", new { area = "admin" }));
                }
                else
                {
                    TempData["Error"] = "Deleting Section Failed";
                    return(RedirectToAction("Index", "section", new { area = "admin" }));
                }
            }

            return(View());
        }
Example #5
0
        public ActionResult DeleteCourse(int courseId)
        {
            if (!_courseRepository.CourseExists(courseId))
            {
                return(NotFound());
            }

            var course = _courseRepository.GetCourse(courseId);

            //Delete course Media
            System.IO.File.Delete(Path.Combine(course.CoursePicturePath));
            System.IO.File.Delete(Path.Combine(course.CoursePreviewVideoPath));


            //There is a conflict with the section table
            //if the course has sections delete them too
            //The conflict arise in one-to-many relationshsips

            if (_courseRepository.GetAllSectionOfACourse(courseId).Count() > 0)
            {
                var sections = _courseRepository.GetAllSectionOfACourse(courseId);
                foreach (var section in sections)
                {
                    if (!_sectionRepository.DeleteSection(section))
                    {
                        return(BadRequest(ModelState));
                    }
                }
            }
            if (!_courseRepository.DeleteCourse(course))
            {
                ModelState.AddModelError("", $"Something went wrong!");
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            return(NoContent());
        }
Example #6
0
 public bool DeleteSection(System.Int32 SectionId)
 {
     return(_iSectionRepository.DeleteSection(SectionId));
 }
Example #7
0
 public bool DeleteSection(int courseId, int levelId, int?typeId)
 {
     return(sectionRepository.DeleteSection(courseId, levelId, typeId));
 }
Example #8
0
 public void Delete(int id)
 {
     repo.DeleteSection(id);
 }
Example #9
0
 public int DeleteSection(int id)
 {
     return(_iSectionRepository.DeleteSection(id));
 }
Example #10
0
 public void DeleteSection(Section section)
 {
     _sectionRepository.DeleteSection(section);
 }