public ActionResult Edit(int id) { ViewBag.CompanyType = new SelectList(CompanyRepo.All().Select(p => new { CompanyType = p.客戶分類 }).Distinct(), "CompanyType", "CompanyType"); var data = CompanyRepo.Find(id); if (data == null) { throw new InvalidOperationException("操作錯誤"); } return(View(data)); }
public ActionResult Create() { ViewBag.CompanyType = new SelectList(CompanyRepo.All().Select(p => new { CompanyType = p.客戶分類 }).Distinct(), "CompanyType", "CompanyType"); return(View("Edit", CompanyRepo.Find(0))); }
// GET: /Company public ActionResult Index(QueryCompanyModel model) { ViewBag.CompanyType = new SelectList(CompanyRepo.All().Select(p => new { CompanyType = p.客戶分類 }).Distinct(), "CompanyType", "CompanyType", model.CompanyType); return(View(CompanyRepo.Query(model, 1))); }