public virtual JsonResult Crear(NormaRequisito entidad) { var jsonResponse = new JsonResponse { Success = false }; if (ModelState.IsValid) { try { entidad.UsuarioCreacion = UsuarioActual.IdUsuario.ToString(); entidad.UsuarioModificacion = UsuarioActual.IdUsuario.ToString(); if (entidad.NRE_Descripcion == null) entidad.NRE_Descripcion = ""; NormaRequisitoBL.Instancia.Add(entidad); jsonResponse.Success = true; jsonResponse.Message = "Se Proceso con éxito"; } catch (Exception ex) { logger.Error(string.Format("Mensaje: {0} Trace: {1}", ex.Message, ex.StackTrace)); jsonResponse.Message = "Ocurrio un error, por favor intente de nuevo o más tarde."; } } else { jsonResponse.Message = "Por favor ingrese todos los campos requeridos"; } return Json(jsonResponse, JsonRequestBehavior.AllowGet); }
public virtual ActionResult Crear() { try { var entidad = new NormaRequisito { NRE_Nombre = string.Empty }; PrepararDatos(ref entidad, "Crear"); return PartialView("Edit", entidad); } catch (Exception ex) { logger.Error(string.Format("Mensaje: {0} Trace: {1}", ex.Message, ex.StackTrace)); return new HttpNotFoundWithViewResult("Error"); } }
private void PrepararDatos(ref NormaRequisito entidad, string accion) { entidad.Accion = accion; ViewData["idMenu"] = this.IdMenu; entidad.IdMenu = this.IdMenu; entidad.IdModulo = this.IdModulo; entidad.Estados = Utils.EnumToList<TipoEstado>(); }