public ActionResult Crear(Orden orden) { if (ModelState.IsValid) { if (orden.ClienteId == 0) { ModelState.AddModelError("ClienteId", "Seleccione un cliente"); return(View(orden)); } _ordenesBL.GuardarOrden(orden); return(RedirectToAction("Index")); } var clientes = _clientesBL.ObtenerClientes(); ViewBag.ClienteId = new SelectList(clientes, "Id", "Nombre"); return(View(orden)); }
public ActionResult Crear(Orden orden) { if (ModelState.IsValid) { if (orden.BeneficiarioId == 0) { ModelState.AddModelError("BeneficiarioId", "Selecciones un beneficiario"); return(View(orden)); } _ordenesBL.GuardarOrden(orden); return(RedirectToAction("Index")); } var beneficiarios = _beneficiariosBL.ObtenerBeneficiariosActivos(); ViewBag.BeneficiarioId = new SelectList(beneficiarios, "Id", "Nombre"); return(View(orden)); }