示例#1
0
 public ActionResult Query(QueryDemandViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         List<Demand> demands = repository.Demands.ToList();
         List<DemandView> demandViews
             = demands.Select(x => DemandView.Parse(x))
             .Where(p =>
                 (viewModel.CurrentCities == null ||
                 viewModel.CurrentCities.FirstOrDefault(x => x == p.City) != null)
                 && p.ReceiveDate >= viewModel.BeginDate && p.ReceiveDate <= viewModel.EndDate
                 && (p.Satisfactory == viewModel.Satisfactory || viewModel.Satisfactory == null)).ToList();
         ViewBag.Title = "需求列表查询结果与导出";
         foreach (DemandView demand in demandViews)
         {
             demand.AllowFinish = userRepository.UserCanEditCity(CurrentUser, demand.City);
         }
         TempData["Demands"] = demandViews;
         return View("QueryResult", demandViews);
     }
     else
     {
         TempData["warning"] = "输入有误。请重新输入";
         return View();
     }
 }
示例#2
0
 public ViewResult Query(string city)
 {
     ListProviders.SetListProvider(() => new DemandListProvider());
     QueryDemandViewModel viewModel = new QueryDemandViewModel
     {
         CurrentCities = string.IsNullOrEmpty(city) ? new List<string>() : new List<string> { city },
         BeginDate = DateTime.Now.AddDays(-180),
         EndDate = DateTime.Now
     };
     ViewBag.Title = "客户需求查询";
     return View(viewModel);
 }