Exemplo n.º 1
0
        public ActionResult Searche(int?pageIndex, String query)
        {
            var countElementPage                 = 10;
            EmployesRepositery empRp             = new EmployesRepositery();
            AspNetUsers        user              = new AspNetUsers();
            PolesModel         pole              = new PolesModel();
            var employers                        = empRp.getSerachingemployees(query);
            List <EmployeesModel> employersModel = new List <EmployeesModel>();

            foreach (var emp in employers)
            {
                var            polId    = emp.Pole_ID != null ? emp.Pole_ID : null;
                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.Pole_ID     = emp.Pole_ID;
                empModel.AspNetUsers = empRp.getUserById(emp.User_ID);
                empModel.Poles.Name  = empRp.getPoleById(emp.Pole_ID).Name;
                employersModel.Add(empModel);
            }
            IQueryable <EmployeesModel>    listEmp = employersModel.AsQueryable();
            PaginatedList <EmployeesModel> lst     = new PaginatedList <EmployeesModel>(listEmp, pageIndex, countElementPage);

            return(View("Allmployes", lst));
        }
Exemplo n.º 2
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));
        }