Exemple #1
0
        /// <summary>
        /// Metodo que se encarga de eliminar o desactivar un registro  de la tabla Perfil
        /// </summary>
        /// <param name="pPerfil"></param>
        /// <returns></returns>
        public RespuestaPerfil EliminarPerfil(Perfil pPerfil)
        {
            int             filasAfectadas;
            RespuestaPerfil respuesta = new RespuestaPerfil();

            //STRORE PROCEDURE DEFINITION
            DbCommand dbCommand = database1.GetStoredProcCommand(defaultSchema + StoredProcedure.EliminarPerfil);

            //IN PARAMETERS


            //OUT PARAMETERS
            database1.AddOutParameter(dbCommand, parameterName(BaseEntidad.codErrorProperty), DbType.String, 2);
            database1.AddOutParameter(dbCommand, parameterName(BaseEntidad.mensajeProperty), DbType.String, 200);

            filasAfectadas = database1.ExecuteNonQuery(dbCommand);

            //ERROR CODE AND MESSAGE COLLECTOR
            respuesta.Respuesta            = new Respuesta();
            respuesta.Respuesta.CodMensaje = DBHelper.ReadNullSafeString(database1.GetParameterValue(dbCommand, parameterName(BaseEntidad.codErrorProperty)));
            respuesta.Respuesta.Mensaje    = DBHelper.ReadNullSafeString(database1.GetParameterValue(dbCommand, parameterName(BaseEntidad.mensajeProperty)));

            if (respuesta.Respuesta.CodMensaje == Respuesta.CodExitoso)
            {
                respuesta.Respuesta = new Respuesta(Mensajes.bmDeletePerfil, respuesta.Respuesta.CodMensaje);
            }

            return(respuesta);
        }
Exemple #2
0
        /// <summary>
        /// Metodo que se utiliza para modificar la informacion en la tabla Perfil
        /// </summary>
        /// <param name="pPerfil"></param>
        /// <returns></returns>
        public RespuestaPerfil ModificarPerfil(Perfil pPerfil)
        {
            int             filasAfectadas;
            RespuestaPerfil respuesta = new RespuestaPerfil();

            //STRORE PROCEDURE DEFINITION
            DbCommand dbCommand = database1.GetStoredProcCommand(defaultSchema + StoredProcedure.ModificarPerfil);

            //IN PARAMETERS

            database1.AddInParameter(dbCommand, parameterName(Perfil.idPerfilProperty), DbType.Int64, pPerfil.IdPerfil);
            database1.AddInParameter(dbCommand, parameterName(Perfil.nombreProperty), DbType.AnsiString, pPerfil.Nombre);
            database1.AddInParameter(dbCommand, parameterName(Perfil.estadoProperty), DbType.String, pPerfil.Estado);
            database1.AddInParameter(dbCommand, parameterName(Perfil.indSuperUsuarioProperty), DbType.Boolean, pPerfil.IndSuperUsuario);
            database1.AddInParameter(dbCommand, parameterName(BaseEntidad.usrModificacionProperty), DbType.String, pPerfil.UsrModificacion);

            //OUT PARAMETERS
            database1.AddOutParameter(dbCommand, parameterName(BaseEntidad.codErrorProperty), DbType.String, 2);
            database1.AddOutParameter(dbCommand, parameterName(BaseEntidad.mensajeProperty), DbType.String, 200);

            filasAfectadas = database1.ExecuteNonQuery(dbCommand);

            //ERROR CODE AND MESSAGE COLLECTOR
            respuesta.Respuesta            = new Respuesta();
            respuesta.Respuesta.CodMensaje = DBHelper.ReadNullSafeString(database1.GetParameterValue(dbCommand, parameterName(BaseEntidad.codErrorProperty)));
            respuesta.Respuesta.Mensaje    = DBHelper.ReadNullSafeString(database1.GetParameterValue(dbCommand, parameterName(BaseEntidad.mensajeProperty)));

            if (respuesta.Respuesta.CodMensaje == Respuesta.CodExitoso)
            {
                respuesta.Respuesta = new Respuesta(Mensajes.bmEditPerfil, respuesta.Respuesta.CodMensaje);
            }

            return(respuesta);
        }
        /// <summary>
        /// Metodo que sirve para Modificar un objeto de tipo Perfil
        /// </summary>
        /// <param name="pPerfil"></param>
        /// <returns></returns>
        public RespuestaPerfil ModificarPerfil(Perfil pPerfil)
        {
            var respuesta = new RespuestaPerfil();

            try
            {
                string        CodigoAlerta = "PerfilEdit";
                List <string> mensajes     = new List <string>();

                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pPerfil.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    //VALIDACION: Entidad no puede venir vacio
                    pPerfil.UsrModificacion = respS.Sesion.CodigoUsuario;

                    if (ValidacionesModificacion(pPerfil, ref mensajes))
                    {
                        respuesta = dal.ModificarPerfil(pPerfil);
                        //LnBitacoraAuditoria.RegistrarBitacora(respuesta, pPerfil, ACCIONES.MODIFICAR);
                        Notificacion(pPerfil, CodigoAlerta);
                    }
                    else
                    {
                        //NO COMPLETA LA VALIDACION, SE ENVIAN DE REGRESO LOS MENSAJES
                        respuesta = new RespuestaPerfil {
                            Respuesta = new Respuesta(Respuesta.CodNoValido), Perfil = respuesta.Perfil
                        };
                    }
                    return(respuesta);
                }
                else
                {
                    return new RespuestaPerfil {
                               Respuesta = respS.Respuesta, Perfil = new Perfil()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pPerfil);
                return(new RespuestaPerfil {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }
        /// <summary>
        /// Metodo que sirve para Obtener la lista de tipo Perfil
        /// </summary>
        /// <param name="pPerfil">Filtro de tipo Perfil</param>
        /// <returns></returns>
        public RespuestaPerfil ObtenerPerfil(Perfil pPerfil)
        {
            var respuesta = new RespuestaPerfil();

            try
            {
                RespuestaSesion respS = sesion.ObtenerSesion(new Sesion()
                {
                    Token = pPerfil.UsrtokensAuthenticate
                });
                if (respS.Respuesta.CodMensaje == Respuesta.CodExitoso)
                {
                    respuesta.Perfil = dal.ObtenerPerfil(pPerfil).ListaPerfil?[0];

                    return(respuesta.Perfil != null ?
                           new RespuestaPerfil {
                        Respuesta = new Respuesta(string.Empty, Respuesta.CodExitoso), Perfil = respuesta.Perfil
                    } :
                           new RespuestaPerfil {
                        Respuesta = new Respuesta(Respuestas.GI03, Respuesta.CodExitoso), Perfil = new Perfil()
                    });
                }
                else
                {
                    return new RespuestaPerfil {
                               Respuesta = respS.Respuesta, Perfil = new Perfil()
                    }
                };
            }
            catch (Exception ex)
            {
                ControlExcepciones.ControlExcepciones.ManejoExcepciones(ex, pPerfil);
                return(new RespuestaPerfil {
                    Respuesta = new Respuesta(TipoRespuesta.Excepcion, ex.Message, Respuesta.CodNoValido)
                });
            }
        }