//======================專案列表(tProject)==========================// //==========列表==========// // GET: Project public ActionResult List() { var projects = db.tProjects.ToList(); List <CVM_ProjectTeamMember> list = new List <CVM_ProjectTeamMember>(); for (int i = 0; i < projects.Count(); i++) { CVM_ProjectTeamMember prjmeb = new CVM_ProjectTeamMember(); prjmeb.project = projects[i]; prjmeb.members = db.tTeamMembers.Where(p => p.fProjectId == prjmeb.project.fProjectId).ToList(); list.Add(prjmeb); } return(View(list)); }
//======================專案表(tProject)=====================// public ActionResult List() { string key = Request.Form["txtKey"]; List <CVM_ProjectTeamMember> list = null; if (string.IsNullOrEmpty(key)) { var projects = db.tProjects.ToList(); list = new List <CVM_ProjectTeamMember>(); for (int i = 0; i < projects.Count(); i++) { CVM_ProjectTeamMember prjmeb = new CVM_ProjectTeamMember(); prjmeb.project = projects[i]; prjmeb.members = db.tTeamMembers.Where(p => p.fProjectId == prjmeb.project.fProjectId).ToList(); list.Add(prjmeb); } } else { var projects = (from p in db.tProjects where p.fProjectName.Contains(key) || p.fProjectId.ToString().Contains(key) select p).ToList(); list = new List <CVM_ProjectTeamMember>(); for (int i = 0; i < projects.Count(); i++) { CVM_ProjectTeamMember prjmeb = new CVM_ProjectTeamMember(); prjmeb.project = projects[i]; prjmeb.members = db.tTeamMembers.Where(p => p.fProjectId == prjmeb.project.fProjectId).ToList(); list.Add(prjmeb); } } return(View(list)); }