// GET: Home public ActionResult Index() { var _context = new DbCaimanContext(); /*var allProjet = GetAllProjets();*/ var VmAllP = new AllProjets(); /* var ctx = _context.Projets.Include(MP => MP.ProjetMembers) * .ThenInclude(mem => mem.Member).SingleOrDefault(c=>c.ProjetId == 1);*/ /* var ctx1 = Mapper.DynamicMap<Projet, ProjetsDTO>(ctx); */ var idallPr = _context.Projets.ToList(); List <ProjetsDTO> allProjetMembers = new List <ProjetsDTO>(); foreach (var item in idallPr) { var ctx2 = _context.Projets.Include(MP => MP.ProjetMembers) .ThenInclude(mem => mem.Member).FirstOrDefault(c => c.ProjetId == item.ProjetId); if (ctx2 != null) { ProjetsDTO monMApp = Mapper.Map <Projet, ProjetsDTO>(ctx2); allProjetMembers.Add(monMApp); } } ViewBag.Alls = allProjetMembers.Where(c => c.IsArchieved == false).OrderByDescending(x => x.ProjetId);; VmAllP.Specialites = GetSpecilites(); return(View(VmAllP)); }
public ActionResult ArchiveAllProjet(int page = 0) { var _context = new DbCaimanContext(); /*var allProjet = GetAllProjets();*/ var VmAllP = new AllProjets(); var ctx = _context.Projets.Include(MP => MP.ProjetMembers) .ThenInclude(mem => mem.Member).SingleOrDefault(c => c.ProjetId == 1); var ctx1 = Mapper.DynamicMap <Projet, ProjetsDTO>(ctx); var idallPr = _context.Projets.ToList(); List <ProjetsDTO> allProjetMembers = new List <ProjetsDTO>(); foreach (var item in idallPr) { var ctx2 = _context.Projets.Include(MP => MP.ProjetMembers) .ThenInclude(mem => mem.Member).FirstOrDefault(c => c.ProjetId == item.ProjetId); if (ctx2 != null) { ProjetsDTO monMApp = Mapper.Map <Projet, ProjetsDTO>(ctx2); allProjetMembers.Add(monMApp); } } var bedroom = allProjetMembers.Where(c => c.IsArchieved == true); const int PageSize = 3; // you can always do something more elegant to set this var count = bedroom.Count(); var data = bedroom.Skip(page * PageSize).Take(PageSize).ToList().OrderByDescending(x => x.ProjetId); ViewBag.MaxPage = (count / PageSize) - (count % PageSize == 0 ? 1 : 0); ViewBag.Page = page; ViewBag.Alls = data; VmAllP.Specialites = GetSpecilites(); return(View(VmAllP)); }