public NivelAcceso Find(Guid uid) { SqlCommand command = new SqlCommand(); try { command.CommandText = "usp_NivelAcceso_Find"; command.CommandType = CommandType.StoredProcedure; command.AddParameter("@UidNivelAcceso", uid, SqlDbType.UniqueIdentifier); DataTable table = new Connection().ExecuteQuery(command); foreach (DataRow row in table.Rows) { NivelAcceso nivel = new NivelAcceso() { UidNivelAcceso = (Guid)row["UidNivelAcceso"], StrNivelAcceso = (string)row["VchNivelAcceso"] }; return(nivel); } } catch (SqlException e) { throw new DatabaseException("Error fetching NivelAcceso", e); } return(null); }
public List <NivelAcceso> FindAll() { List <NivelAcceso> Niveles = new List <NivelAcceso>(); SqlCommand command = new SqlCommand(); try { command.CommandText = "usp_NivelAcceso_FindAll"; command.CommandType = CommandType.StoredProcedure; DataTable table = new Connection().ExecuteQuery(command); foreach (DataRow row in table.Rows) { NivelAcceso nivel = new NivelAcceso() { UidNivelAcceso = (Guid)row["UidNivelAcceso"], StrNivelAcceso = (string)row["VchNivelAcceso"] }; Niveles.Add(nivel); } } catch (SqlException e) { throw new DatabaseException("Error fetching Modulos", e); } return(Niveles); }