public ActionResult Edit(DepartamentoModel model, string submitButton) { if (Session["User"] != null) { Service1Client client = new Service1Client(); switch (submitButton) { case "Buscar": var hola = client.getDepartamento(model.id); if (hola == null) { client.Close(); return View(); } ViewBag.Desc = hola.descripcion; ViewBag.id = hola.departamentoid; break; case "Modificar": if (ModelState.IsValid) { client.editDepartamento(model.id, model.descripcion); } break; } client.Close(); return View(); } else { return RedirectToAction("Login", "Home"); } }
public ActionResult Index(DepartamentoModel model) { if (Session["User"] != null) { if (ModelState.IsValid) { Service1Client client = new Service1Client(); client.addDepartamentos(model.descripcion); client.Close(); } return View(); } else { return RedirectToAction("Login"); } }