public void Validar() { if (string.IsNullOrWhiteSpace(Cidade)) { throw new OpenWeatherException("A cidade informada não é válida"); } if (Descricoes == null || Descricoes.Length == 0) { throw new OpenWeatherException("Nenhuma descrição informada"); } else if (Descricoes.Any(x => string.IsNullOrWhiteSpace(x))) { throw new OpenWeatherException("Nenhuma descrição válida informada"); } if (TemperatuaMinima > TemperatuaMaxima) { throw new OpenWeatherException("A temperatura mínima informada é maior que a temperatura máxima"); } if (Temperatua < TemperatuaMinima) { throw new OpenWeatherException("A temperatura informada é menor que a temperatura mínima"); } if (Temperatua > TemperatuaMaxima) { throw new OpenWeatherException("A temperatura informada é maior que a temperatura máxima"); } }
public Descricoes ConsultaDescricao() { Descricoes _Retorno = new Descricoes(); try { using (HanaConnection conn = new HanaConnection(ConfigurationManager.ConnectionStrings["Hana"].ConnectionString)) { conn.Open(); var Schema = ConfigurationManager.AppSettings["CompanyDB"]; string Sql = string.Format(Properties.Resources.ConsultaDescricao, Schema); using (HanaCommand cmd3 = new HanaCommand(Sql, conn)) { using (HanaDataReader productInfoReader3 = cmd3.ExecuteReader()) { HanaCommand cmd = new HanaCommand(Sql, conn); HanaDataReader productInfoReader = cmd.ExecuteReader(); if (productInfoReader.HasRows) { productInfoReader.Read(); string Code = productInfoReader.GetString(0); string Name = productInfoReader.GetString(1); string Count = productInfoReader.GetString(2); _Retorno.value = new Descricao[int.Parse(Count)]; _Retorno.value[0] = new Descricao(); _Retorno.value[0].Code = Code; _Retorno.value[0].Name = Name; int i = 1; while (productInfoReader.Read()) { Code = productInfoReader.GetString(0); Name = productInfoReader.GetString(1); _Retorno.value[i] = new Descricao(); _Retorno.value[i].Code = Code; _Retorno.value[i].Name = Name; i++; } } } } } } catch (Exception ex) { Log.Error(ex.Message); } finally { } return(_Retorno); }