public ActionResult Update(客戶銀行資訊[] Banks, int PageIndex) { if (ModelState.IsValid) { foreach (客戶銀行資訊 data in Banks) { if (!data.IsDelete) { data.IsDelete = false; } else { data.是否已刪除 = !data.是否已刪除; } this.bankRepository.UnitOfWork.Context.Entry(data).State = EntityState.Modified; } this.bankRepository.UnitOfWork.Commit(); return RedirectToAction("Index", new { PageIndex }); } else { BankViewModel model = new BankViewModel(); model.PageIndex = PageIndex; model.Banks = this.bankRepository.PagedToList(PageIndex, pageNum); model.Customers = this.customerRepository.All(); return View("Index", model); } }
// GET: /Banks/ public ActionResult Index(BankViewModel model) { model.Banks = this.bankRepository.PagedToList(model.PageIndex, pageNum); model.Customers = this.customerRepository.All(); return View(model); }