public ActionResult AllExpanseTypes(int?pageIndex)
        {
            var                    countElementPage = 10;
            TvasRepositery         tvaRepo          = new TvasRepositery();
            TvasModel              tvaModel         = new TvasModel();
            ExpanseTypesRepositery expTypeRep       = new ExpanseTypesRepositery();
            var                    expanseTypes     = expTypeRep.allExpanseTypes();

            if (expanseTypes.Count() == 0)
            {
                ViewData["erreurMessage"] = "Aucun type de frais !";
                ViewData["create"]        = "true";
                ViewData["element"]       = "ExpanseTypes";
                return(View("ErrorEmptyList"));
            }
            if (User.IsInRole("manager"))
            {
                expanseTypes = expTypeRep.allExpanseTypesManager();
            }

            List <ExpanseTypesModel> expanseTypesModel = new List <ExpanseTypesModel>();

            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;
                tvaModel.Name         = tvaRepo.tvasById(expTpe.Tva_ID).Name;
                tvaModel.TVA_ID       = tvaRepo.tvasById(expTpe.Tva_ID).TVA_ID;
                tvaModel.Value        = tvaRepo.tvasById(expTpe.Tva_ID).Value;
                expenseTypeModel.Tvas = tvaModel;
                expanseTypesModel.Add(expenseTypeModel);
            }
            IQueryable <ExpanseTypesModel>    listEpanTypes = expanseTypesModel.AsQueryable();
            PaginatedList <ExpanseTypesModel> lst           = new PaginatedList <ExpanseTypesModel>(listEpanTypes, pageIndex, countElementPage);

            return(View("AllExpansesTypes", 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));
        }