Exemplo n.º 1
0
        public ActionResult Delete(Guid id)
        {
            ExpanseRepportRepositery expRep    = new ExpanseRepportRepositery();
            ExpanseReports           expReport = expRep.GetById(id);

            expRep.Delete(expReport);
            expRep.Save();
            return(RedirectToAction("AllExpansesReports"));
        }
        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"));
        }