public ActionResult Delete(Guid id) { ProjetRepositery prjtRepo = new ProjetRepositery(); Projects project = prjtRepo.GetById(id); ExpanseRepositery expRep = new ExpanseRepositery(); ExpanseRepportRepositery expRepRep = new ExpanseRepportRepositery(); List <Expanses> expList = expRep.GetByProject(id).ToList(); foreach (var expanse in expList) { expRep.Delete(expanse); } expRep.Save(); prjtRepo.Delete(project); prjtRepo.Save(); return(RedirectToAction("AllProjets")); }
public ActionResult Delete(Guid id) { PolesRepository poleRep = new PolesRepository(); ProjetRepositery prjtRepo = new ProjetRepositery(); ExpanseRepositery expRep = new ExpanseRepositery(); EmployesRepositery empRepo = new EmployesRepositery(); ExpanseRepportRepositery expRepRep = new ExpanseRepportRepositery(); List <Projects> projets = prjtRepo.GetByIdPole(id).ToList(); foreach (var pro in projets) { List <Expanses> expList = expRep.GetByProject(pro.Project_ID).ToList(); foreach (var expanse in expList) { expRep.Delete(expanse); } expRep.Save(); prjtRepo.Delete(pro); } prjtRepo.Save(); foreach (var empl in empRepo.getByIdPole(id)) { List <ExpanseReports> expanseReports = expRepRep.GetByEmployesId(empl.Employee_ID).ToList(); foreach (var expRepo in expanseReports) { expRepRep.Delete(expRepo); } expRepRep.Save(); empRepo.Delete(empl); } empRepo.Save(); Poles pole = poleRep.GetById(id); poleRep.Delete(pole); poleRep.Save(); return(RedirectToAction("AllPoles")); }