Example #1
0
 public List <Estructura> Listar(EstructuraFiltro filtro = null)
 {
     using (_contexto = new ALICORPContexto())
     {
         try
         {
             _repositorio = new EstructuraRepositorio(_contexto.Connection);
             return(_repositorio.Listar(filtro));
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Example #2
0
        public List <Estructura> Listar(EstructuraFiltro filtro)
        {
            List <Estructura> lista = new List <Estructura>();

            try
            {
                using (var cmd = CreateCommand())
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "usp_Estructura_Listar";

                    cmd.Parameters.AddWithValue("@tablero", filtro?.Tablero ?? Convert.DBNull);

                    using (var rd = cmd.ExecuteReader())
                    {
                        while (rd.Read())
                        {
                            lista.Add(new Estructura
                            {
                                Id          = rd.GetInt32(0),
                                PadreId     = !rd.IsDBNull(1) ? rd.GetInt32(1) : (int?)null,
                                Codigo      = !rd.IsDBNull(2) ? rd.GetString(2) : null,
                                Descripcion = rd.GetString(3),
                                Tablero     = rd.GetBoolean(4)
                            });
                        }
                        rd.Close();
                    }
                }
                return(lista);
            }
            catch (Exception)
            {
                throw new Exception("OcurriĆ³ un problema al listar las estructuras.");
            }
        }