public ActionResult Search(string keyword) { SelectList selectList = new SelectList(customerType.GetAll().ToList(), "Id", "類別名稱"); ViewBag.CustType = selectList; if (string.IsNullOrEmpty(keyword)) { return(View("Index", customer.GetAll())); } if (customer.Exists(x => x.客戶名稱.Contains(keyword)) == false) { return(HttpNotFound()); } IEnumerable <客戶資料> result = customer.Query(x => x.客戶名稱.Contains(keyword)); return(View("Index", result)); }
public ActionResult Search(string keyword) { if (string.IsNullOrEmpty(keyword)) { return(View("Index", customerBank.GetAll())); } if (customer.Exists(x => x.客戶名稱.Contains(keyword)) == false) { return(HttpNotFound()); } var id = customer.Query(x => x.客戶名稱.Contains(keyword)).Select(x => x.Id).ToList(); var result = customerBank.GetAll().Where(x => id.Contains(x.客戶Id)); return(View("Index", result)); }