/// <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);
        }
Beispiel #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);
        }