public GenericResponse ModificarDatosUsuario(UpdateUsuarioRequest request, string _operation) { GenericResponse _response = new GenericResponse(); try { if (_conectorBD.UpdateDatosUsuario(request, _operation)) { Informacion.LogInformacion(LogManager.GetCurrentClassLogger(), " [ " + GerenteLog.GetObtenerMetodo() + " ] -- [ " + _operation + " ]. Se Modifico al cliente con email: " + request.correoElectronico + " , de manera correcta."); _response.codigo = GerenteCodigo.GetCodigo("OK"); _response.mensaje = GerenteMensaje.GetMensaje("OK"); _response.exito = true; } else { Informacion.LogInformacion(LogManager.GetCurrentClassLogger(), " [ " + GerenteLog.GetObtenerMetodo() + " ] -- [ " + _operation + " ]. Ocurrio un error al modificar al cliente con email: " + request.correoElectronico); _response.codigo = GerenteCodigo.GetCodigo("ERROR_FATAL"); _response.mensaje = GerenteMensaje.GetMensaje("ERROR_FATAL"); _response.exito = false; } } catch (Exception ex) { _response.codigo = GerenteCodigo.GetCodigo("ERROR_FATAL"); _response.mensaje = GerenteMensaje.GetMensaje("ERROR_FATAL"); _response.exito = false; Informacion.LogError(LogManager.GetCurrentClassLogger(), " [ " + GerenteLog.GetObtenerMetodo() + " ] -- [ " + _operation + " ].Se genero un error inesperado. ", ex); } return(_response); }
public string ModificarData(UpdateUsuarioRequest request) { _operation = GerenteOperacion.GenerarOperacion(); _conectorNegocio = new NegocioObtenerDatos(); GenericResponse _response = new GenericResponse(); bool estado = false; try { Informacion.LogInformacion(LogManager.GetCurrentClassLogger(), " [ " + GerenteLog.GetObtenerMetodo() + " ] -- [ " + _operation + " ] REQUEST: " + GerenteJson.SerializeObject(request)); if (ModelState.IsValid) { _response = _conectorNegocio.VerificarCanal(request.Canal, request.PassCanal, _operation, ref estado); if (!estado) { return(GerenteJson.SerializeObject(_response)); } _response = _conectorNegocio.ModificarDatosUsuario(request, _operation); Informacion.LogInformacion(LogManager.GetCurrentClassLogger(), " [ " + GerenteLog.GetObtenerMetodo() + " ] -- [ " + _operation + " ] RESPONSE: " + GerenteJson.SerializeObject(_response)); } else { var errors = string.Join(" | ", ModelState.Values .SelectMany(v => v.Errors) .Select(e => e.ErrorMessage)); _response.mensaje = Convert.ToString(errors); return(GerenteJson.SerializeObject(_response)); } } catch (Exception ex) { Informacion.LogError(LogManager.GetCurrentClassLogger(), " [ " + GerenteLog.GetObtenerMetodo() + " ] -- [ " + _operation + " ]. Se genero un error en Modificar los datos.", ex); } return(JsonConvert.SerializeObject(_response)); }
public GenericResponse MandarDatosUsuario(UsuarioRequest request, string _operation) { GenericResponse _response = new GenericResponse(); try { #region Encryptar contraseña de usuario string Password = String.Empty; Encryptador.EncryptDecrypt(true, request.password, ref Password); request.password = Password; #endregion if (_conectorBD.InsertDatosUsuario(request, _operation)) { _response.codigo = GerenteCodigo.GetCodigo("OK"); _response.mensaje = GerenteMensaje.GetMensaje("OK"); _response.exito = true; Informacion.LogInformacion(LogManager.GetCurrentClassLogger(), " [ " + GerenteLog.GetObtenerMetodo() + " ] -- [ " + _operation + " ]. Se guardo de manera correcta al cliente con email: " + request.correo_Electronico); } else { Informacion.LogInformacion(LogManager.GetCurrentClassLogger(), " [ " + GerenteLog.GetObtenerMetodo() + " ] -- [ " + _operation + " ]. Ocurrio un error al guardar al cliente con email: " + request.correo_Electronico); _response.codigo = 400; _response.mensaje = "No se pudo registrar la informacion del usuario en base de datos"; _response.exito = false; } } catch (Exception ex) { _response.codigo = GerenteCodigo.GetCodigo("ERROR_FATAL"); _response.mensaje = GerenteMensaje.GetMensaje("ERROR_FATAL"); _response.exito = false; Informacion.LogError(LogManager.GetCurrentClassLogger(), " [ " + GerenteLog.GetObtenerMetodo() + " ] -- [ " + _operation + " ]. Se genero un error inesperado. ", ex); } return(_response); }
public bool UpdateDatosUsuario(UpdateUsuarioRequest request, string _operation) { bool _response = false; try { string nombreSp = "[api].[UPDATE_DATOS_USUARIO]"; StoreProcedure sp = new StoreProcedure(nombreSp); sp.AgregarParametro("@USSER", request.nameUser, Direccion.Input); sp.AgregarParametro("@PASS", request.passUser, Direccion.Input); sp.AgregarParametro("@CORREO", request.correoElectronico, Direccion.Input); sp.AgregarParametro("@CELULAR", request.celular, Direccion.Input); sp.EjecutarStoreProcedure(strConexion_wpp); if (sp.Error.Trim() != String.Empty) { _response = false; throw new Exception("Procedimiento Almacenado: " + nombreSp + " Descripcion: " + sp.Error.Trim()); } _response = true; } catch (Exception ex) { Informacion.LogError(LogManager.GetCurrentClassLogger(), " [ " + GerenteLog.GetObtenerMetodo() + " ] -- [ " + _operation + " ]. Se genero un error inesperado en Base de Datos BD_DATOS", ex); } return(_response); }
public bool InsertDatosUsuario(UsuarioRequest data, string _operation) { bool response = false; try { string nombreSp = "[api].[INSERT_DATOS_USUARIO]"; StoreProcedure sp = new StoreProcedure(nombreSp); sp.AgregarParametro("@NOMBRE", data.nombre.ToUpper(), Direccion.Input); sp.AgregarParametro("@CORREO_ELECTRONICO", data.correo_Electronico.ToUpper(), Direccion.Input); sp.AgregarParametro("@CELULAR", data.celular, Direccion.Input); sp.AgregarParametro("@USER", data.usuario.ToUpper(), Direccion.Input); sp.AgregarParametro("@PASSWORD", data.password, Direccion.Input); sp.EjecutarStoreProcedure(strConexion_wpp); if (sp.Error.Trim() != String.Empty) { response = false; throw new Exception("Procedimiento Almacenado: " + nombreSp + " Descripcion: " + sp.Error.Trim()); } response = true; } catch (Exception ex) { Informacion.LogError(LogManager.GetCurrentClassLogger(), GerenteLog.GetObtenerMetodo(), ex); } return(response); }
public GenericResponse VerificarCanal(string canal, string passCanal, string _operation, ref bool estado) { DataTable datos = new DataTable(); GenericResponse _respuesta = new GenericResponse(); try { string password = String.Empty; bool habilitado = false; datos = _conectorBD.Get_Canales(canal, _operation); if (datos.Rows.Count == 1) { foreach (DataRow item in datos.Rows) { password = item.Field <string>("PASS_CANAL"); habilitado = item.Field <bool>("HABILITADO"); } if (habilitado) { Encryptador.EncryptDecrypt(false, password, ref password); estado = password == passCanal ? true : false; if (!estado) { _respuesta.mensaje = "La contraseña proporcionada no es la correcta."; _respuesta.codigo = 401; _respuesta.exito = false; } else { _respuesta.mensaje = GerenteMensaje.GetMensaje("OK"); _respuesta.codigo = GerenteCodigo.GetCodigo("OK"); _respuesta.exito = true; } } else { _respuesta.mensaje = "El canal " + canal + " no se encuentra habilitado para el uso del metodo."; _respuesta.codigo = 401; _respuesta.exito = false; } } else if (datos.Rows.Count == 0) { _respuesta.mensaje = "No se encuentra ninguna información sobre el canal"; _respuesta.codigo = 404; _respuesta.exito = false; } } catch (Exception ex) { Informacion.LogError(LogManager.GetCurrentClassLogger(), " [ " + GerenteLog.GetObtenerMetodo() + " ] -- [ " + _operation + " ]. Se genero un error inesperado. ", ex); } return(_respuesta); }
public GenericResponse IniciarSecion(InicioUsuario request, string _operation) { GenericResponse _response = new GenericResponse(); try { DataTable dmo = new DataTable(); dmo = _conectorBD.Get_Usuario(request, _operation); if (dmo.Rows.Count == 1) { foreach (DataRow item in dmo.Rows) { string pass = String.Empty; Encryptador.EncryptDecrypt(false, item.Field <string>("CONTRASEÑA"), ref pass); if (pass.Equals(request.contraseñaUsuario) && item.Field <string>("NOMBRE_USUARIO").Equals(request.nombreUsuario.Trim().ToUpper())) { _response.mensaje = GerenteMensaje.GetMensaje("OK"); _response.codigo = GerenteCodigo.GetCodigo("OK"); _response.exito = true; } else { _response.mensaje = "La contraseña o usuario son incorrectas"; _response.codigo = 400; _response.exito = true; } } } else if (dmo.Rows.Count == 0) { _response.mensaje = "CREAR CUENTA"; _response.codigo = 401; _response.exito = true; } } catch (Exception ex) { Informacion.LogError(LogManager.GetCurrentClassLogger(), " [ " + GerenteLog.GetObtenerMetodo() + " ] -- [ " + _operation + " ]. Se genero un error inesperado. ", ex); } return(_response); }
public DataTable Get_Usuario(InicioUsuario request, string _operation) { DataTable datos = new DataTable(); try { StoreProcedure sp = new StoreProcedure("[api].[GET_USUARIO_INICIO]"); sp.AgregarParametro("", request.nombreUsuario, Direccion.Input); sp.AgregarParametro("", request.contraseñaUsuario, Direccion.Input); datos = sp.RealizarConsulta(strConexion_wpp); if (sp.Error != String.Empty) { throw new Exception("Procedimiento Almacenado: [api].[GET_USUARIO_INICIO] - Descripcion: " + sp.Error); } } catch (Exception ex) { Informacion.LogError(LogManager.GetCurrentClassLogger(), " [ " + GerenteLog.GetObtenerMetodo() + " ] -- [ " + _operation + " ]. Se genero un error inesperado. ", ex); } return(datos); }
public DataTable Get_Canales(string canal, string _operation) { DataTable data = new DataTable(); try { string nombre = "[api].[GET_CANALES]"; StoreProcedure sp = new StoreProcedure(nombre); sp.AgregarParametro("@CANAL", canal, Direccion.Input); data = sp.RealizarConsulta(strConexion_wpp); if (sp.Error != String.Empty) { throw new Exception("Procedimiento Almacenado: " + nombre + " Descripcion: " + sp.Error.Trim()); } } catch (Exception ex) { Informacion.LogError(LogManager.GetCurrentClassLogger(), " [ " + GerenteLog.GetObtenerMetodo() + " ] -- [ " + _operation + " ]. Se genero un error inesperado en Base de Datos BD_DATOS", ex); } return(data); }