public ActionResult createPole(PolesModel poleModel)
        {
            if (!ModelState.IsValid)
            {
                PolesRepository  poleRep       = new PolesRepository();
                EmployeesModel   empModel      = new EmployeesModel();
                List <Employees> lisEmpManager = poleRep.getAllManager();
                Debug.WriteLine("nombre d element :" + lisEmpManager.Count());
                if (lisEmpManager.ToList().Count() == 0)
                {
                    ViewData["erreur"] = "Employers";
                    return(View("ErrorEmptyElement"));
                }
                foreach (Employees emp in lisEmpManager)
                {
                    Debug.WriteLine("element de list :" + emp.Email);
                    empModel.Employee_ID = emp.Employee_ID;
                    empModel.FirstName   = emp.FirstName;
                    poleModel.Employees.Add(empModel);
                    break;
                }
                return(View("PoleFormulaire", poleModel));
            }
            Poles           pole   = new Poles();
            PolesRepository polRep = new PolesRepository();

            pole.Pole_ID    = Guid.NewGuid();
            pole.Name       = Convert.ToString(Request.Form["Name"]);
            pole.Manager_ID = new Guid(Convert.ToString(Request.Form["managerSelect"]));
            polRep.AddPoles(pole);
            return(RedirectToAction("AllPoles"));
        }
        public ActionResult AllPoles(int?pageIndex)
        {
            PolesRepository polRep           = new PolesRepository();
            var             countElementPage = 10;
            var             poles            = polRep.allPoles();

            if (poles.Count() == 0)
            {
                ViewData["erreurMessage"] = "Aucun pole!";
                ViewData["element"]       = "Poles";
                ViewData["create"]        = "true";
                return(View("ErrorEmptyList"));
            }
            List <PolesModel> ploesModel = new List <PolesModel>();

            foreach (var pol in poles)
            {
                PolesModel polModel = new PolesModel();
                polModel.Pole_ID = pol.Pole_ID;
                polModel.Name    = pol.Name;
                ploesModel.Add(polModel);
            }
            IQueryable <PolesModel>    listPoles = ploesModel.AsQueryable();
            PaginatedList <PolesModel> lst       = new PaginatedList <PolesModel>(listPoles, pageIndex, countElementPage);

            return(View("AllPoles", lst));
        }
        public ActionResult Edit(Guid id)
        {
            PolesRepository polRep    = new PolesRepository();
            PolesModel      poleModel = new PolesModel();
            Poles           pole      = polRep.GetById(id);

            poleModel.Pole_ID    = pole.Pole_ID;
            poleModel.Name       = pole.Name;
            poleModel.Manager_ID = pole.Manager_ID;
            return(View("EditPoles", poleModel));
        }
Exemplo n.º 4
0
        public ActionResult AllEmployees(int?pageIndex)
        {
            var countElementPage     = 10;
            EmployesRepositery empRp = new EmployesRepositery();
            AspNetUsers        user  = new AspNetUsers();

            PolesRepository poleRepo  = new PolesRepository();
            var             employers = empRp.allEmployees();

            if (employers.Count() == 0)
            {
                ViewData["erreurMessage"] = "Aucun employer !";
                ViewData["create"]        = "false";
                return(View("ErrorEmptyList"));
            }
            List <EmployeesModel> employersModel = new List <EmployeesModel>();

            foreach (var emp in employers)
            {
                EmployeesModel empModel = new EmployeesModel();
                empModel.Email       = emp.Email;
                empModel.Employee_ID = emp.Employee_ID;
                empModel.FirstName   = emp.FirstName;
                empModel.LastName    = emp.LastName;
                empModel.Telephone   = emp.Telephone;
                empModel.User_ID     = emp.User_ID;
                empModel.AspNetUsers = empRp.getUserById(emp.User_ID);
                if (emp.Poles == null)
                {
                    PolesModel pole = new PolesModel();
                    pole.Name      = "inconnu";
                    empModel.Poles = pole;
                }
                else
                {
                    PolesModel pole = new PolesModel();
                    pole.Pole_ID   = emp.Poles.Pole_ID;
                    pole.Name      = emp.Poles.Name;
                    empModel.Poles = pole;
                }

                employersModel.Add(empModel);
            }
            IQueryable <EmployeesModel>    listEmp = employersModel.AsQueryable();
            PaginatedList <EmployeesModel> lst     = new PaginatedList <EmployeesModel>(listEmp, pageIndex, countElementPage);

            return(View("AllEmployes", lst));
        }
        public ActionResult updatePole(Guid id)
        {
            PolesRepository polRep = new PolesRepository();
            Poles           pole   = polRep.GetById(id);

            if (!ModelState.IsValid)
            {
                PolesModel poleModel = new PolesModel();
                poleModel.Pole_ID    = pole.Pole_ID;
                poleModel.Name       = pole.Name;
                poleModel.Manager_ID = pole.Manager_ID;
                return(View("EditPoles", poleModel));
            }
            String name = Convert.ToString(Request.Form["Name"]);

            polRep.updatePole(pole, name);
            return(RedirectToAction("AllPoles"));
        }
        public ActionResult Searche(String query, int?pageIndex)
        {
            var               countElementPage = 10;
            PolesRepository   polRep           = new PolesRepository();
            var               poles            = polRep.getSerachingPoles(query);
            List <PolesModel> polesModel       = new List <PolesModel>();

            foreach (var pl in poles)
            {
                PolesModel poleModel = new PolesModel();
                poleModel.Pole_ID    = pl.Pole_ID;
                poleModel.Name       = pl.Name;
                poleModel.Manager_ID = pl.Manager_ID;
                polesModel.Add(poleModel);
            }
            IQueryable <PolesModel>    listPoles = polesModel.AsQueryable();
            PaginatedList <PolesModel> lst       = new PaginatedList <PolesModel>(listPoles, pageIndex, countElementPage);

            return(View("AllPoles", lst));
        }
        // GET: Poles
        public ActionResult Index()
        {
            PolesModel       pole          = new PolesModel();
            PolesRepository  poleRep       = new PolesRepository();
            EmployeesModel   empModel      = new EmployeesModel();
            List <Employees> lisEmpManager = poleRep.getAllManager();

            Debug.WriteLine("nombre d element :" + lisEmpManager.Count());
            if (lisEmpManager.ToList().Count() == 0)
            {
                ViewData["erreur"] = "Employers";
                return(View("ErrorEmptyElement"));
            }
            foreach (Employees emp in lisEmpManager)
            {
                empModel.Employee_ID = emp.Employee_ID;
                empModel.FirstName   = emp.FirstName;
                pole.Employees.Add(empModel);
                break;
            }
            return(View("PoleFormulaire", pole));
        }
        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"));
        }