Пример #1
0
 public virtual ActionResult Crear()
 {
     try
     {
         var entidad = new NormaMuestreo
                           {
                               NOM_Nombre = string.Empty,
                               NOM_Acreditador = string.Empty,
                               NOM_Descripcion = 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");
     }
 }
Пример #2
0
        public virtual JsonResult Crear(NormaMuestreo entidad)
        {
            var jsonResponse = new JsonResponse {Success = false};

            if (ModelState.IsValid)
            {
                try
                {
                    entidad.UsuarioCreacion = UsuarioActual.IdUsuario.ToString();
                    entidad.UsuarioModificacion = UsuarioActual.IdUsuario.ToString();
                    // data temporal
                    //entidad.NOM_Acreditador = entidad.NOM_Nombre + " - NOM_Acreditador";
                    //entidad.NOM_Anio = 2013;
                    if (entidad.NOM_Acreditador == null)
                        entidad.NOM_Acreditador = "";
                    if (entidad.NOM_Anio == null)
                        entidad.NOM_Anio = DateTime.Now.Year;
                    if (entidad.NOM_Descripcion == null)
                        entidad.NOM_Descripcion = "";
                    // fin data
                    NormaMuestreoBL.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);
        }
Пример #3
0
        private void PrepararDatos(ref NormaMuestreo entidad, string accion)
        {
            entidad.Accion = accion;

            ViewData["idMenu"] = this.IdMenu;
            entidad.IdMenu = this.IdMenu;
            entidad.IdModulo = this.IdModulo;
            entidad.Estados = Utils.EnumToList<TipoEstado>();
        }