public async Task <IActionResult> Delete([FromForm] SectionViewModel model) { var section = await repo.GetSectionAsync(model.Id); repo.DeleteSection(section); await repo.SaveAsync(); return(RedirectToAction("Index")); }
public ActionResult <Section> DeleteSection(int id) { var sc = _sectionRepo.DeleteSection(id); if (sc == null) { return(NotFound()); } return(sc); }
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()); }
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()); }
public bool DeleteSection(System.Int32 SectionId) { return(_iSectionRepository.DeleteSection(SectionId)); }
public bool DeleteSection(int courseId, int levelId, int?typeId) { return(sectionRepository.DeleteSection(courseId, levelId, typeId)); }
public void Delete(int id) { repo.DeleteSection(id); }
public int DeleteSection(int id) { return(_iSectionRepository.DeleteSection(id)); }
public void DeleteSection(Section section) { _sectionRepository.DeleteSection(section); }