Example #1
0
        public List <Amigo> GetAmigos()
        {
            var result = new List <Amigo>();

            try
            {
                if (_client.Open())
                {
                    var command = new SqlCommand
                    {
                        Connection  = _client.Conecction,
                        CommandText = "getamigos",
                        CommandType = CommandType.StoredProcedure
                    };
                    var dataReader = command.ExecuteReader();
                    while (dataReader.Read())
                    {
                        var amigo = new Amigo
                        {
                            idamigo   = Convert.ToInt32(dataReader["idamigo"].ToString()),
                            nombre    = dataReader["nombre"].ToString(),
                            fecnac    = Convert.ToDateTime(dataReader["fecnac"].ToString()),
                            direccion = dataReader["direccion"].ToString(),
                            telefono  = dataReader["telefono"].ToString()
                        };
                        result.Add(amigo);
                    }
                }
            }
            catch
            {
                // ignored
            }
            finally
            {
                _client.Close();
            }

            return(result);
        }
Example #2
0
        public List <Lista> GetCity(string nombre)
        {
            var result = new List <Lista>();

            try
            {
                if (_client.Open())
                {
                    var command = new SqlCommand
                    {
                        Connection  = _client.Conecction,
                        CommandText = "getcity",
                        CommandType = CommandType.StoredProcedure
                    };
                    var par1 = new SqlParameter("@nombre", SqlDbType.NVarChar)
                    {
                        Direction = ParameterDirection.Input,
                        Value     = nombre
                    };
                    command.Parameters.Add(par1);
                    var dataReader = command.ExecuteReader();
                    while (dataReader.Read())
                    {
                        var ciudad = new Lista
                        {
                            id       = Convert.ToInt32(dataReader["idciudad"].ToString()),
                            name     = dataReader["nombre"].ToString(),
                            country  = dataReader["pais"].ToString(),
                            timezone = Convert.ToInt32(dataReader["tiempohorario"].ToString()),
                            sunrise  = Convert.ToInt32(dataReader["amanecer"].ToString()),
                            sunset   = Convert.ToInt32(dataReader["anochecer"].ToString()),
                            temp     = Convert.ToDouble(dataReader["temperatura"].ToString()),
                            temp_max = Convert.ToDouble(dataReader["temperaturamax"].ToString()),
                            temp_min = Convert.ToDouble(dataReader["temperaturamin"].ToString()),
                        };
                        result.Add(ciudad);
                    }
                }
            }
            catch
            {
                // ignored
            }
            finally
            {
                _client.Close();
            }

            return(result);
        }