public ActionResult Edit(int id) { var banco = _context.Bancos.SingleOrDefault(c => c.BancoId == id); if (banco == null) { return(HttpNotFound()); } var viewModel = new BancoFormViewModel(banco); return(View("BancoForm", viewModel)); }
public ActionResult Save(Bancos banco) { if (!ModelState.IsValid) { var viewMosdel = new BancoFormViewModel(banco); return(View("BancoForm", viewMosdel)); } if (banco.BancoId == 0) { _context.Bancos.Add(banco); } else { var bancoInDb = _context.Bancos.Single(c => c.BancoId == banco.BancoId); bancoInDb.BancoId = banco.BancoId; bancoInDb.NombreBanco = banco.NombreBanco; } _context.SaveChanges(); return(RedirectToAction("Index", "Banco")); }
public ActionResult BancoForm() { var viewModel = new BancoFormViewModel(); return(View("BancoForm", viewModel)); }