public ActionResult AllProjets(int?pageIndex)
        {
            ProjetRepositery prtRep = new ProjetRepositery();
            int countElementPage    = 10;
            var projets             = prtRep.allProjects();

            if (projets.Count() == 0)
            {
                ViewData["erreurMessage"] = "Aucun Projet!";
                ViewData["element"]       = "Projet";
                ViewData["create"]        = "true";
                return(View("ErrorEmptyList"));
            }
            List <ProjectsModel> projetsModel = new List <ProjectsModel>();

            foreach (var prjt in projets)
            {
                ProjectsModel  prjtModel = new ProjectsModel();
                CustomersModel Customer  = new CustomersModel();
                prjtModel.Project_ID  = prjt.Project_ID;
                prjtModel.Pole_ID     = prjt.Pole_ID;
                prjtModel.Description = prjt.Description;
                prjtModel.Budget      = prjt.Budget;
                prjtModel.Name        = prjt.Name;
                Customer.Name         = prtRep.GetByIdCutomer(prjt.Customer_ID).Name;
                prjtModel.Customers   = Customer;
                projetsModel.Add(prjtModel);
            }
            IQueryable <ProjectsModel>    listProjets = projetsModel.AsQueryable();
            PaginatedList <ProjectsModel> lst         = new PaginatedList <ProjectsModel>(listProjets, pageIndex, countElementPage);

            return(View("AllProjects", lst));
        }
        public PartialViewResult ListProject(Guid customerId)
        {
            ProjetRepositery      prjtRepo          = new ProjetRepositery();
            IQueryable <Projects> projectsList      = prjtRepo.GetProjectsByIdCutomer(customerId);
            List <ProjectsModel>  projectsListModel = new List <ProjectsModel>();

            foreach (var prjt in projectsList)
            {
                ProjectsModel  prjtModel = new ProjectsModel();
                CustomersModel Customer  = new CustomersModel();
                prjtModel.Project_ID  = prjt.Project_ID;
                prjtModel.Pole_ID     = prjt.Pole_ID;
                prjtModel.Description = prjt.Description;
                prjtModel.Budget      = prjt.Budget;
                prjtModel.Name        = prjt.Name;
                Customer.Name         = prjtRepo.GetByIdCutomer(prjt.Customer_ID).Name;
                prjtModel.Customers   = Customer;
                projectsListModel.Add(prjtModel);
            }
            var expanseViewModel = new ExpansesModel
            {
                ProjectsList = projectsListModel
            };

            return(PartialView("_ProjectItem", expanseViewModel));
        }
        public ActionResult Searche(String query, int?pageIndex)
        {
            var countElementPage       = 10;
            ProjetRepositery projetRep = new ProjetRepositery();
            var projets = projetRep.getSerachingProjects(query);
            List <ProjectsModel> projetsModel = new List <ProjectsModel>();
            CustomersModel       customer     = new CustomersModel();

            foreach (var prjt in projets)
            {
                ProjectsModel prjtModel = new ProjectsModel();
                prjtModel.Project_ID  = prjt.Project_ID;
                prjtModel.Pole_ID     = prjt.Pole_ID;
                prjtModel.Description = prjt.Description;
                prjtModel.Budget      = prjt.Budget;
                prjtModel.Name        = prjt.Name;
                customer.Name         = projetRep.GetByIdCutomer(prjt.Customer_ID).Name;
                prjtModel.Customers   = customer;
                projetsModel.Add(prjtModel);
            }
            IQueryable <ProjectsModel>    listProjets = projetsModel.AsQueryable();
            PaginatedList <ProjectsModel> lst         = new PaginatedList <ProjectsModel>(listProjets, pageIndex, countElementPage);

            return(View("AllProjects", lst));
        }
        public ActionResult Popup(Guid idExpanseReport)
        {
            CustomerRepositery       cstRepo               = new CustomerRepositery();
            ProjetRepositery         prjtRepo              = new ProjetRepositery();
            ExpanseTypesRepositery   expTypRepo            = new ExpanseTypesRepositery();
            List <CustomersModel>    customersModel        = new List <CustomersModel>();
            List <ProjectsModel>     projectsListModel     = new List <ProjectsModel>();
            List <ExpanseTypesModel> expansesTypeListModel = new List <ExpanseTypesModel>();

            ViewData["empty"] = "false";

            IQueryable <Customers> costumers = cstRepo.getlistCustomersHasProject();

            foreach (var cust in costumers)
            {
                CustomersModel custModel = new CustomersModel();
                custModel.Customer_ID = cust.Customer_ID;
                custModel.Code        = cust.Code;
                custModel.Name        = cust.Name;
                customersModel.Add(custModel);
            }

            IQueryable <Projects> projectsList = prjtRepo.allProjects();

            foreach (var prjt in projectsList)
            {
                ProjectsModel  prjtModel = new ProjectsModel();
                CustomersModel Customer  = new CustomersModel();
                prjtModel.Project_ID  = prjt.Project_ID;
                prjtModel.Pole_ID     = prjt.Pole_ID;
                prjtModel.Description = prjt.Description;
                prjtModel.Budget      = prjt.Budget;
                prjtModel.Name        = prjt.Name;
                Customer.Name         = prjtRepo.GetByIdCutomer(prjt.Customer_ID).Name;
                prjtModel.Customers   = Customer;
                projectsListModel.Add(prjtModel);
            }

            IQueryable <ExpanseTypes> expanseTypes = expTypRepo.allExpanseTypes();

            if (User.IsInRole("manager"))
            {
                expanseTypes = expTypRepo.allExpanseTypesManager();
            }

            foreach (var expTpe in expanseTypes)
            {
                ExpanseTypesModel expenseTypeModel = new ExpanseTypesModel();
                expenseTypeModel.ExpenseType_ID = expTpe.ExpenseType_ID;
                expenseTypeModel.Name           = expTpe.Name;
                expenseTypeModel.Ceiling        = expTpe.Ceiling;
                expenseTypeModel.Fixed          = expTpe.Fixed;
                expenseTypeModel.OnlyManagers   = expTpe.OnlyManagers;
                expenseTypeModel.Tva_ID         = expTpe.Tva_ID;
                expansesTypeListModel.Add(expenseTypeModel);
            }

            if (customersModel.Count() == 0 || projectsListModel.Count() == 0 || expansesTypeListModel.Count() == 0)
            {
                ViewData["erreur"] = "Customers , Projets et des ExpanseType";
                ViewData["empty"]  = "true";
            }
            var expanseViewModel = new ExpansesModel
            {
                CustomersList    = customersModel,
                ProjectsList     = projectsListModel,
                ExpanseTypesList = expansesTypeListModel
            };

            expanseViewModel.ExpanseReport_ID = idExpanseReport;

            return(PartialView("_AddType", expanseViewModel));
        }