public List <IObjetoTexto> LeerTabla() { List <IObjetoTexto> lista = new List <IObjetoTexto>(); try { String[] lineas = _contenido.Split("\n"); for (int i = 0; i < lineas.Length; i++) { lineas[i] = lineas[i].Trim(); if (!lineas[i].Equals("")) { IObjetoTexto _objeto = ModeloFactory.darInstancia(_tipo); lista.Add(_objeto.leerTexto(lineas[i])); } } } catch (Exception ex) { System.Console.WriteLine("Ha ocurrido un Error: " + ex.Message); } return(lista); }
public Mensaje PutUsuario(int id, String sesionId, JsonElement objeto) { if (Sesion.VerificarSesion(sesionId, true) != null) { if (objeto.TryGetProperty("id", out JsonElement jsonId) && !jsonId.ToString().Equals(id.ToString())) { return(Mensaje.DATOS_ID); } String identificador = "Id"; Dictionary <String, String> campos = ModeloFactory.ValidarNulos <Usuario>(objeto, identificador); if (campos.Count > 0) { KeyValuePair <String, String> condicion = new KeyValuePair <string, string>(identificador, campos[identificador]); if (objeto.TryGetProperty("contrasena", out JsonElement jsonCon)) { campos["Contrasena"] = Utilidades.encriptarContrasena(campos["Nombre"], campos["Contrasena"]); } if (ModeloFactory.Modificar <Usuario>(campos, condicion)) { return(Mensaje.MODIFICO_EXITO); } } return(Mensaje.NO_MODIFICAR); } return(Mensaje.SESION_INCORRECTA); }
public List <T> LeerTabla <T>() { List <T> lista = new List <T>(); String query = "Select * from " + typeof(T).Name; SQLiteCommand cmd = conexion.CreateCommand(); cmd.CommandText = query; SQLiteDataReader lector = cmd.ExecuteReader(); while (lector.Read()) { if (lector.HasRows && lector.FieldCount > 0) { IModeloBase objeto = ModeloFactory.darInstancia(typeof(T)); List <String> listaCampos = objeto.OrdenCampos(); Dictionary <String, String> excepciones = objeto.Excepciones(); foreach (String campo in listaCampos) { if (!campo.Trim().Equals("")) { PropertyInfo propiedad = _tipo.GetProperty(campo); Utilidades.PasarValorCampo(excepciones, propiedad, objeto, lector[propiedad.Name].ToString()); } } lista.Add((T)objeto); } } return(lista); }
public Object GetRol(int id, String sesionId) { if (Sesion.VerificarSesion(sesionId, true) != null) { return(ModeloFactory.Obtener <Rol>(new KeyValuePair <String, String>("id", id.ToString()))); } return(Mensaje.SESION_INCORRECTA); }
public Object GetRoles(String sesionId) { if (Sesion.VerificarSesion(sesionId, true) != null) { return(ModeloFactory.Listar <Rol>()); } return(Mensaje.SESION_INCORRECTA); }
public Object GetUsuarioTareas(String sesionId) { Usuario usuario = Sesion.VerificarSesion(sesionId); if (usuario != null) { return(ModeloFactory.Obtener <Tarea>(new KeyValuePair <String, String>("usuario", usuario.Id.ToString()))); } return(Mensaje.SESION_INCORRECTA); }
public Object PostRol(String sesionId, Rol rol) { if (Sesion.VerificarSesion(sesionId, true) != null) { if (ModeloFactory.Crear(rol)) { return(GetRol(rol.Id, sesionId)); } } return(Mensaje.SESION_INCORRECTA); }
public Object PostUsuario(String sesionId, Usuario usuario) { if (Sesion.VerificarSesion(sesionId, true) != null) { if (ModeloFactory.Crear(usuario)) { return(GetUsuario(usuario.Id, sesionId)); } } return(Mensaje.SESION_INCORRECTA); }
public Object DeleteUsuario(int id, String sesionId) { if (Sesion.VerificarSesion(sesionId, true) != null) { Usuario usuario = ModeloFactory.Obtener <Usuario>(new KeyValuePair <string, string>("Id", id.ToString())); if (usuario == null) { if (ModeloFactory.Eliminar <Usuario>(new KeyValuePair <string, string>("Id", id.ToString()))) { return(usuario); } } } return(Mensaje.SESION_INCORRECTA); }
public Object DeleteRol(int id, String sesionId) { if (Sesion.VerificarSesion(sesionId, true) != null) { Rol rol = ModeloFactory.Obtener <Rol>(new KeyValuePair <string, string>("Id", id.ToString())); if (rol == null) { return(Mensaje.DATOS_ID); } if (ModeloFactory.Eliminar <Rol>(new KeyValuePair <string, string>("Id", id.ToString()))) { return(rol); } } return(Mensaje.SESION_INCORRECTA); }
// Protected implementation of Dispose pattern. protected virtual void Dispose(bool disposing) { if (disposed) { return; } if (disposing) { // Free any other managed objects here. factory = null; } // Free any unmanaged objects here. // disposed = true; }
public Mensaje PutRol(int id, String sesionId, JsonElement objeto) { if (Sesion.VerificarSesion(sesionId, true) != null) { if (objeto.TryGetProperty("id", out JsonElement jsonId) && !jsonId.ToString().Equals(id.ToString())) { return(Mensaje.DATOS_ID); } if (ModeloFactory.Modificar <Rol>(objeto, "Id")) { return(Mensaje.MODIFICO_EXITO); } return(Mensaje.NO_MODIFICAR); } return(Mensaje.SESION_INCORRECTA); }
public Mensaje PutUsuario(int id, String sesionId, Usuario usuario) { if (Sesion.VerificarSesion(sesionId, true) != null) { if (id != usuario.Id) { return(Mensaje.DATOS_ID); } if (ModeloFactory.Modificar(usuario, "Id")) { return(Mensaje.MODIFICO_EXITO); } return(Mensaje.NO_MODIFICAR); } return(Mensaje.SESION_INCORRECTA); }
public Mensaje PutRol(int id, String sesionId, Rol rol) { if (Sesion.VerificarSesion(sesionId, true) != null) { if (id != rol.Id) { return(Mensaje.DATOS_ID); } if (ModeloFactory.Modificar(rol, "Id")) { return(Mensaje.MODIFICO_EXITO); } return(Mensaje.NO_MODIFICAR); } return(Mensaje.SESION_INCORRECTA); }
private List <T> ConvertirDeTexto <T>(string contenido) { List <T> lista = new List <T>(); if (contenido != null && !contenido.Trim().Equals("")) { String[] lineas = contenido.Split("\n").Select(p => p.Trim()).ToArray(); foreach (String linea in lineas) { if (!linea.Trim().Equals("")) { String[] camposValor = linea.Split("\t").Select(p => p.Trim()).ToArray(); IModeloBase objeto = ModeloFactory.darInstancia(typeof(T)); IngresarContenido(objeto, camposValor); lista.Add((T)objeto); } } } return(lista); }
public ModeloRepository() { factory = new ModeloFactory(); }