예제 #1
0
        /// <summary>
        /// Valida los valores principales del objeto.
        /// </summary>
        /// <remarks>
        ///     Registro de versiones:
        ///
        ///         1.0 15/06/2016 Marcos Abraham Hernández Bravo (Ada Ltda.): versión inicial.
        /// </remarks>
        /// <returns>
        ///     Retorna <code>true</code> en caso de ser válido, o <code>false</code> de lo contrario.
        /// </returns>
        public virtual Notificacion <bool> Validar()
        {
            Notificacion <bool> retorno = new Notificacion <bool>();

            retorno.Respuesta = true;

            if (string.IsNullOrEmpty(Tabla))
            {
                retorno.AgregarMensaje(Notificacion.TABLA_POR_DEFECTO_MENSAJES, "ERROR_VACIO", "Tabla");
                retorno.Respuesta = false;
            }

            if (string.IsNullOrEmpty(Codigo))
            {
                retorno.AgregarMensaje(Notificacion.TABLA_POR_DEFECTO_MENSAJES, "ERROR_VACIO", "Codigo");
                retorno.Respuesta = false;
            }

            if (string.IsNullOrEmpty(Idioma))
            {
                retorno.AgregarMensaje(Notificacion.TABLA_POR_DEFECTO_MENSAJES, "ERROR_VACIO", "Idioma");
                retorno.Respuesta = false;
            }

            if (string.IsNullOrEmpty(Pais))
            {
                retorno.AgregarMensaje(Notificacion.TABLA_POR_DEFECTO_MENSAJES, "ERROR_VACIO", "Pais");
                retorno.Respuesta = false;
            }

            return(retorno);
        }
예제 #2
0
        public Notificacion <T> Modificar(T entidad)
        {
            Notificacion <T> retorno = new Notificacion <T>();

            retorno.Respuesta = entidad;
            string nombreEntidad = typeof(T).Name.Replace("TO", string.Empty);

            try
            {
                Notificacion <bool> respuestaExiste = Existe(entidad);

                if (respuestaExiste.HayError || respuestaExiste.HayExcepcion)
                {
                    retorno.Unir(respuestaExiste);
                    return(retorno);
                }

                if (respuestaExiste.Respuesta)
                {
                    DAO.Modificar(entidad);
                    retorno.AgregarMensaje(nombreEntidad, "Modificar_OK");
                }
                else
                {
                    retorno.AgregarMensaje(nombreEntidad, "Error_No_Existe");
                }
            }
            catch (Exception ex)
            {
                retorno.AgregarMensaje(nombreEntidad, "Modificar_Error", null, null, null, null, ex);
            }

            return(retorno);
        }
예제 #3
0
        /// <summary>
        /// Persiste los cambios de una entidad.
        /// </summary>
        /// <remarks>
        ///     Registro de versiones:
        ///
        ///         1.0 02/08/2016 Marcos Abraham Hernández Bravo (Ada Ltda.): versión inicial.
        /// </remarks>
        /// <param name="entidad">Mensaje a persistir.</param>
        /// <returns>Mensaje persistido.</returns>
        public Notificacion <MensajeTO> Modificar(MensajeTO entidad)
        {
            Notificacion <MensajeTO> retorno = new Notificacion <MensajeTO>();

            retorno.Respuesta = entidad;
            try
            {
                Notificacion <bool> respuestaExiste = Existe(entidad);

                if (respuestaExiste.HayError || respuestaExiste.HayExcepcion)
                {
                    retorno.Unir(respuestaExiste);
                    return(retorno);
                }

                if (respuestaExiste.Respuesta)
                {
                    DAO.Modificar(entidad);
                    retorno.AgregarMensaje("Mensaje", "Modificar_OK");
                }
                else
                {
                    retorno.AgregarMensaje("Mensaje", "Error_No_Existe");
                }
            }
            catch (Exception ex)
            {
                retorno.AgregarMensaje("Mensaje", "Modificar_Error", null, null, null, null, ex);
            }

            return(retorno);
        }
예제 #4
0
        public Notificacion <IList <Campo> > ObtenerCampos(Tabla tabla)
        {
            Notificacion <IList <Campo> > retorno = new Notificacion <IList <Campo> >();

            try
            {
                retorno.Respuesta = dao.ObtenerCampos(tabla);
            }
            catch (EjecutarException ee)
            {
                retorno.AgregarMensaje(ee.Message, Severidad.Error, null, null, ee);
            }
            catch (ArgumentException ae)
            {
                retorno.AgregarMensaje(ae.Message, Severidad.Error, null, null, ae);
            }
            catch (ConexionException ce)
            {
                retorno.AgregarMensaje(ce.Message, Severidad.Error, null, null, ce);
            }
            return(retorno);
        }
예제 #5
0
        public Notificacion <IList <BaseDatos> > ObtenerBasesDatos(bool incluirBasesSistema)
        {
            Notificacion <IList <BaseDatos> > retorno = new Notificacion <IList <BaseDatos> >();

            try
            {
                retorno.Respuesta = dao.ObtenerBasesDatos(incluirBasesSistema);
            }
            catch (EjecutarException ee)
            {
                retorno.AgregarMensaje(ee.Message, Severidad.Error, null, null, ee);
            }
            catch (ArgumentException ae)
            {
                retorno.AgregarMensaje(ae.Message, Severidad.Error, null, null, ae);
            }
            catch (ConexionException ce)
            {
                retorno.AgregarMensaje(ce.Message, Severidad.Error, null, null, ce);
            }
            return(retorno);
        }
예제 #6
0
        /// <summary>
        /// Obtiene las entidades según los valores de un filtro.
        /// </summary>
        /// <remarks>
        ///     Registro de versiones:
        ///
        ///         1.0 02/08/2016 Marcos Abraham Hernández Bravo (Ada Ltda.): versión inicial.
        /// </remarks>
        /// <param name="filtro">Mensaje de filtro</param>
        /// <returns>Colección de mensajes que cumplen el filtro.</returns>
        public Notificacion <IList <MensajeTO> > ObtenerSegunFiltro(MensajeTO filtro)
        {
            Notificacion <IList <MensajeTO> > retorno = new Notificacion <IList <MensajeTO> >();

            try
            {
                retorno.Respuesta = DAO.ObtenerSegunFiltro(filtro);
            }
            catch (Exception ex)
            {
                retorno.AgregarMensaje("Mensaje", "ObtenerSegunFiltro_Error", null, null, null, null, ex);
            }

            return(retorno);
        }
예제 #7
0
        /// <summary>
        /// Obtiene la entidad según si identificador(es).
        /// </summary>
        /// <remarks>
        ///     Registro de versiones:
        ///
        ///         1.0 02/08/2016 Marcos Abraham Hernández Bravo (Ada Ltda.): versión inicial.
        /// </remarks>
        /// <param name="entidad">Mensaje a buscar.</param>
        /// <returns>Mensaje persistido.</returns>
        public Notificacion <MensajeTO> ObtenerSegunID(MensajeTO entidad)
        {
            Notificacion <MensajeTO> retorno = new Notificacion <MensajeTO>();

            try
            {
                retorno.Respuesta = DAO.ObtenerSegunID(entidad);
            }
            catch (Exception ex)
            {
                retorno.AgregarMensaje("Mensaje", "ObtenerSegunID_Error", null, null, null, null, ex);
            }

            return(retorno);
        }
예제 #8
0
        /// <summary>
        /// Determina la existencia de una entidad en base de datos.
        /// </summary>
        /// <remarks>
        ///     Registro de versiones:
        ///
        ///         1.0 02/08/2016 Marcos Abraham Hernández Bravo (Ada Ltda.): versión inicial.
        /// </remarks>
        /// <param name="entidad">Mensaje a comprobar.</param>
        /// <returns><code>true</code> de existir, o <code>false</code> de lo contrario.</returns>
        public Notificacion <bool> Existe(MensajeTO entidad)
        {
            Notificacion <bool> retorno = new Notificacion <bool>();

            try
            {
                retorno.Respuesta = DAO.Existe(entidad);
            }
            catch (Exception ex)
            {
                retorno.AgregarMensaje("Mensaje", "Existe_Error", null, null, null, null, ex);
            }

            return(retorno);
        }
예제 #9
0
        public Notificacion <bool> Existe(T entidad)
        {
            Notificacion <bool> retorno = new Notificacion <bool>();
            string nombreEntidad        = typeof(T).Name.Replace("TO", string.Empty);

            try
            {
                retorno.Respuesta = DAO.Existe(entidad);
            }
            catch (Exception ex)
            {
                retorno.AgregarMensaje(nombreEntidad, "Existe_Error", null, null, null, null, ex);
            }

            return(retorno);
        }
예제 #10
0
        public Notificacion <IList <T> > ObtenerTodos()
        {
            Notificacion <IList <T> > retorno = new Notificacion <IList <T> >();
            string nombreEntidad = typeof(T).Name.Replace("TO", string.Empty);

            try
            {
                retorno.Respuesta = DAO.ObtenerTodos();
            }
            catch (Exception ex)
            {
                retorno.AgregarMensaje(nombreEntidad, "ObtenerTodos_Error", null, null, null, null, ex);
            }

            return(retorno);
        }