public static CarreraDC CarreraBEConvertirCarreraDC(CarreraEntity oCarreraBE) { try { CarreraDC oCarreraDC = new CarreraDC(); oCarreraDC.CarreraId = oCarreraBE.CarreraId; oCarreraDC.Nombre = oCarreraBE.CarreraNombre; return oCarreraDC; } catch (Exception ex) { throw ex; } }
public static CarreraEntity CarreraDCConvertirCarreraBE(CarreraDC oCarreraDC) { try { CarreraEntity oCarreraEntity = new CarreraEntity(); oCarreraEntity.CarreraId = oCarreraDC.CarreraId; oCarreraEntity.CarreraNombre = oCarreraDC.Nombre; return oCarreraEntity; } catch (Exception ex) { throw ex; } }
public List<CarreraEntity> ListarCarreras() { List<CarreraEntity> lista = new List<CarreraEntity>(); SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["SSIA2013"].ToString()); SqlCommand cmd = cn.CreateCommand(); cmd.CommandText = "[SIGERCOV].[uspListarCarreras]"; cmd.CommandType = CommandType.StoredProcedure; CarreraEntity item = null; try { cn.Open(); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { item = new CarreraEntity(); item.CarreraId = dr.GetInt32(dr.GetOrdinal("CarreraId")); item.CarreraNombre = dr.GetString(dr.GetOrdinal("CarreraNombre")).ToString(); lista.Add(item); } dr.Close(); } catch (Exception ex) { throw ex; } finally { if (cn.State == ConnectionState.Open) { cn.Close(); } cn.Dispose(); cmd.Dispose(); cn = null; cmd = null; } return lista; }