public ActionResult Searche(String query, int?pageIndex, Guid id) { var countElementPage = 10; ExpanseRepositery expRepo = new ExpanseRepositery(); var expanses = expRepo.getSerachingExpanses(query, id); List <ExpansesModel> expanseModel = new List <ExpansesModel>(); ViewData["idExpanseReport"] = id; foreach (var exp in expanses) { ExpansesModel expanse = new ExpansesModel(); CustomersModel customer = new CustomersModel(); ExpanseTypesModel expType = new ExpanseTypesModel(); ExpanseReportsModel expanseRapport = new ExpanseReportsModel(); ProjectsModel projet = new ProjectsModel(); expanse.Expanse_ID = exp.Expanse_ID; expanse.Amount_HT = exp.Amount_HT; expanse.Amount_TTC = exp.Amount_TTC; expanse.Amount_TVA = exp.Amount_TVA; customer.Name = expRepo.GetByIdCutomer(exp.Customer_ID).Name; projet.Name = expRepo.GetByIdProjects(exp.Project_ID).Name; expType.Name = expRepo.GetByIdExpanseTypes(exp.ExpanseType_ID).Name; expanseRapport.Year = expRepo.GetByIdExpansesRepport(exp.ExpanseReport_ID).Year; expanse.Customers = customer; expanse.Projects = projet; expanse.ExpanseReports = expanseRapport; expanse.ExpanseTypes = expType; expanseModel.Add(expanse); } IQueryable <ExpansesModel> listCust = expanseModel.AsQueryable(); PaginatedList <ExpansesModel> lst = new PaginatedList <ExpansesModel>(listCust, pageIndex, countElementPage); return(View("AllExpanses", lst)); }
public ActionResult AllExpanses(int?pageIndex, Guid idExpanseReport) { ExpanseRepositery expRepo = new ExpanseRepositery(); double ttc = 0; double tva = 0; double ht = 0; var countElementPage = 10; var expanses = expRepo.GetAllByIdExpansesRepport(idExpanseReport); ViewData["idExpanseReport"] = idExpanseReport; List <ExpansesModel> expanseModel = new List <ExpansesModel>(); foreach (var exp in expanses) { tva = tva + exp.Amount_TVA; ht = ht + exp.Amount_HT; ttc = ttc + exp.Amount_TTC; ExpansesModel expanse = new ExpansesModel(); CustomersModel customer = new CustomersModel(); ExpanseTypesModel expType = new ExpanseTypesModel(); ExpanseReportsModel expanseRapport = new ExpanseReportsModel(); ProjectsModel projet = new ProjectsModel(); expanseRapport.ExpanseReport_ID = idExpanseReport; expanse.ExpanseReport_ID = exp.Expanse_ID; expanse.Expanse_ID = exp.Expanse_ID; expanse.Amount_HT = exp.Amount_HT; expanse.Amount_TTC = exp.Amount_TTC; expanse.Amount_TVA = exp.Amount_TVA; expanse.Day = exp.Day; customer.Name = expRepo.GetByIdCutomer(exp.Customer_ID).Name; projet.Name = expRepo.GetByIdProjects(exp.Project_ID).Name; expType.Name = expRepo.GetByIdExpanseTypes(exp.ExpanseType_ID).Name; expanseRapport.Year = expRepo.GetByIdExpansesRepport(exp.ExpanseReport_ID).Year; expanse.Customers = customer; expanse.Projects = projet; expanse.ExpanseReports = expanseRapport; expanse.ExpanseTypes = expType; expanseModel.Add(expanse); } ExpanseRepportRepositery expRapRep = new ExpanseRepportRepositery(); ExpanseReports expRap = expRapRep.GetById(idExpanseReport); expRapRep.updateExpanseReports(expRap, ttc, ht, tva); ViewData["idExpanseReport"] = idExpanseReport; IQueryable <ExpansesModel> listExpanse = expanseModel.AsQueryable(); PaginatedList <ExpansesModel> lst = new PaginatedList <ExpansesModel>(listExpanse, pageIndex, countElementPage); return(View("AllExpanses", lst)); }