public Tuple <int, string, string> getById(int id) { TBL_ROL rolToSearch = contexto.TBL_ROL.Find(id); if (rolToSearch != null) { return(new Tuple <int, string, string>(Convert.ToInt32(rolToSearch.ID_ROL), rolToSearch.NOMBRE_ROL, rolToSearch.DESC_ROL)); } else { return(new Tuple <int, string, string>(0, "Rol no encontrado", "")); } }
public static bool updateUser(TBL_ROL _infoRol) { try { bool resul = false; //Actualizar el contexto de datos dc.SubmitChanges(); resul = true; return(resul); } catch (Exception ex) { throw new ArgumentException("Error al consultar los Roles " + ex.Message); } }
public static bool saveRol(TBL_ROL _infoRol) { try { dc = new CD_HelpDeskDataContext(); bool resul = false; dc.TBL_ROL.InsertOnSubmit(_infoRol); //Actualizar el contexto de datos dc.SubmitChanges(); resul = true; return(resul); } catch (Exception ex) { throw new ArgumentException("Error al consultar los Roles " + ex.Message); } }
static void Main(string[] args) { try { Entidades contexto = new Entidades(); TBL_USUARIO usuario = new TBL_USUARIO(); TBL_ROL rol = new TBL_ROL(); //idRol = Convert.ToInt16(contexto.TBL_ROL.Max(u => u.ID_ROL)); //user.ID = id+1; //usuario.RUT_USUARIO = 166485606; //usuario.NOMBRE = "CAMILO"; //usuario.AP_PATERNO = "BOSS"; //usuario.AP_MATERNO = "BOSS"; //usuario.DIR_PARTICULAR = "HELL 666"; //usuario.PASSWORD = "******"; //rol.ID_ROL = idRol; rol.NOMBRE_ROL = "rolsito"; rol.DESC_ROL = "es un rol muy loco"; //agregamos el objeto // contexto.TBL_USUARIO.Add(usuario); //Deshabilitado xq faltan datos en tablas relacionadas :V contexto.TBL_ROL.Add(rol); //guardamos cambios contexto.SaveChanges(); Console.WriteLine("insertado"); Console.ReadKey(); } catch (Exception ex) { try { Console.WriteLine(((ex.InnerException).InnerException).Message); Console.ReadKey(); } catch (Exception ex2) { Console.WriteLine(ex2.ToString()); Console.ReadKey(); } } }
public KeyValuePair <int, string> Delete(int id) { try { TBL_ROL rol = contexto.TBL_ROL.Find(id); if (rol != null) { contexto.TBL_ROL.Remove(rol); contexto.SaveChanges(); return(new KeyValuePair <int, string>(0, "Eliminado Correctamente")); } else { return(new KeyValuePair <int, string>(1, "Rol no encontrado")); } } catch (Exception ex /* dex */) { return(new KeyValuePair <int, string>(2, ex.ToString())); } }
public KeyValuePair <int, string> insert(string nombreRol, string descRol, out int newPK) { newPK = 0; TBL_ROL rol = new TBL_ROL(); try { rol.NOMBRE_ROL = nombreRol; rol.DESC_ROL = descRol; contexto.TBL_ROL.Add(rol); //Se cambio la arquitectura de las capas a x64 por la versiĆ²n del odac instalado //ref: https://stackoverflow.com/questions/26137256/ef-with-oracle-the-specified-store-provider-cannot-be-found-in-the-configurat contexto.SaveChanges(); //extraemos el id de la entidad insertada newPK = Convert.ToInt32(rol.ID_ROL); //context.Database.ExecuteSqlCommand("BEGIN STORED_PROCEDURE_NAME; END; "); para ejecutar procedimientos almacenados ;D return(new KeyValuePair <int, string>(0, "Insertado Correctamente")); } catch (Exception ex /* dex */) { return(new KeyValuePair <int, string>(2, ex.ToString())); } }
public KeyValuePair <int, string> update(int idRol, string nombreRol, string descRol) { try { TBL_ROL rolOriginal = contexto.TBL_ROL.Find(idRol); if (rolOriginal != null) { rolOriginal.NOMBRE_ROL = nombreRol; rolOriginal.DESC_ROL = descRol; contexto.SaveChanges(); return(new KeyValuePair <int, string>(0, "Actualizado Correctamente")); } else { return(new KeyValuePair <int, string>(1, "Rol no encontrado")); } } catch (Exception ex /* dex */) { return(new KeyValuePair <int, string>(2, ex.ToString())); } }
public Mensaje AsignarAccionesRol(TBL_ROL rol) { return(new Mensaje((int)Mensaje.CatTipoMensaje.Exitoso, "contenido", "valor")); }
public Mensaje EliminarRol(TBL_ROL rol) { return(new Mensaje((int)Mensaje.CatTipoMensaje.Exitoso, "contenido", "valor")); }