コード例 #1
0
        // GET: Customer
        public ActionResult Index(string search = "", string 分類 = "")
        {
            var options = (from p in repo.All() select p.分類).Distinct().OrderBy(p => p).ToList();

            ViewBag.分類 = new SelectList(options);

            var data = repo.Filter(search, 分類).ToList();

            return(View(data.ToList()));
        }
コード例 #2
0
        public ActionResult Index(CustomerListViewModel model)
        {
            //var query = db.客戶資料.Where(c => c.是否已刪除 == false).AsQueryable();
            //var query = customerRepo.All();

            //if (!string.IsNullOrWhiteSpace(model.SearchParameter.客戶名稱))
            //{
            //    query = query.Where(
            //        x => x.客戶名稱.Contains(model.SearchParameter.客戶名稱));
            //}
            //if (!string.IsNullOrWhiteSpace(model.SearchParameter.客戶統一編號))
            //{
            //    query = query.Where(
            //        x => x.統一編號.Contains(model.SearchParameter.客戶統一編號));
            //}
            //if (!string.IsNullOrWhiteSpace(model.SearchParameter.客戶Email))
            //{
            //    query = query.Where(
            //        x => x.Email.Contains(model.SearchParameter.客戶Email));
            //}
            //if (!string.IsNullOrWhiteSpace(model.SearchParameter.客戶電話))
            //{
            //    query = query.Where(
            //        x => x.電話.Contains(model.SearchParameter.客戶電話));
            //}
            //if (!string.IsNullOrWhiteSpace(model.SearchParameter.客戶分類))
            //{
            //    query = query.Where(
            //        x => x.客戶分類.Contains(model.SearchParameter.客戶分類));
            //}

            var query = customerRepo.Filter(
                model.SearchParameter.客戶名稱, model.SearchParameter.客戶統一編號, model.SearchParameter.客戶Email,
                model.SearchParameter.客戶電話, model.SearchParameter.客戶分類);
            //ViewBag.客戶分類選項 = customerRepo.All客戶分類().Select(s => new SelectListItem { Text = s, Value = s }).ToList();
            var result = new CustomerListViewModel
            {
                SearchParameter = model.SearchParameter,
                Customers       = query
            };

            return(View(result));
        }