1 public ActionResult Index(ReserveInfoRequest request) 2 { 3 4 List<string> MineList= this.AccountService.GetPermMineList(this.CookieContext.UserId); 5 6 var result = this.ReserveService.GetReserveList(request); 7 8 List<ReserveInfo> Items = new List<ReserveInfo>(); 9 10 foreach (ReserveInfo Reserve in result) 11 { 12 if (MineList[0] == Reserve.MineCode) 13 { 14 Items.Add(Reserve); 15 16 } 17 } 18 PagedList<ReserveInfo> pagedlist = new PagedList<ReserveInfo>(Items, 1, 10); 19 20 // result=result.Where(m => MineList.Contains(m.MineCode)); 21 22 ReserveInfoRequest NewRequest = new ReserveInfoRequest(); 23 var MineNameList = this.ReserveService.GetReserveList(NewRequest); 24 //定义ViewBag.MineName 25 Dictionary<int, String> dictionaryName = new Dictionary<int, string>(); 26 int i = 0; 27 List<String> mineNameList = new List<String>(); 28 foreach (ReserveInfo yearCheck in MineNameList) 29 { 30 if (!mineNameList.Contains(yearCheck.MineName)) 31 { 32 mineNameList.Add(yearCheck.MineName); 33 dictionaryName.Add(i, yearCheck.MineName); 34 i++; 35 } 36 } 37 this.ViewBag.MineName = new SelectList(dictionaryName, "", "value "); 38 39 //定义ViewBag.Year 40 Dictionary<int, String> dictionaryYear = new Dictionary<int, string>(); 41 int j = 0; 42 List<String> YearList = new List<String>(); 43 foreach (ReserveInfo reserve in MineNameList) 44 { 45 if (!YearList.Contains(reserve.Year)) 46 { 47 YearList.Add(reserve.Year); 48 dictionaryYear.Add(j, reserve.Year); 49 j++; 50 } 51 } 52 this.ViewBag.Year = new SelectList(dictionaryYear, "", "value "); 53 54 return View(pagedlist); 55 }