public static List <MenuCircularHome> Listar(int pintId, int pintIdIdioma) { string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString; SqlConnection objConexao = new SqlConnection(strConectionString); SqlCommand objComando = new SqlCommand("SPE_L_MENU_CIRCULAR_HOME"); objComando.Connection = objConexao; objComando.CommandType = CommandType.StoredProcedure; //Define parametros da procedure objComando.Parameters.Add("@conteudoId", SqlDbType.Int).Value = pintId; objComando.Parameters.Add("@idiomaId", SqlDbType.Int).Value = pintIdIdioma; try { //Abre Conexao objConexao.Open(); //Declara variavel de retorno List <MenuCircularHome> objList = new List <MenuCircularHome>(); MenuCircularHome obj = default(MenuCircularHome); IDataReader idrReader = default(IDataReader); idrReader = objComando.ExecuteReader(); while ((idrReader.Read())) { obj = new MenuCircularHome(); obj.FromIDataReader(idrReader); objList.Add(obj); } return(objList); } catch (Exception ex) { throw ex; } finally { //Fecha a conexao se aberta if (objConexao.State != ConnectionState.Closed) { objConexao.Close(); } } }
public static MenuCircularHome ObterMenuCircularHome(int pintIdMenuCircularHome) { string strConectionString = ConfigurationManager.ConnectionStrings["BradescoRI"].ConnectionString; SqlConnection objConexao = new SqlConnection(strConectionString); SqlCommand objComando = new SqlCommand("SPE_L_MENU_CIRCULAR_HOME_ID"); objComando.Connection = objConexao; objComando.CommandType = CommandType.StoredProcedure; objComando.Parameters.Add("@menuCircularHomeId", SqlDbType.Int).Value = pintIdMenuCircularHome; try { objConexao.Open(); MenuCircularHome obj = new MenuCircularHome(); IDataReader idrReader = default(IDataReader); idrReader = objComando.ExecuteReader(); while ((idrReader.Read())) { obj.FromIDataReader(idrReader); } return(obj); } catch (Exception ex) { throw ex; } finally { //Fecha a conexao se aberta if (objConexao.State != ConnectionState.Closed) { objConexao.Close(); } } }