Example #1
0
 internal static IEnumerable <HopsIngredientDataModel> GetHopsIngredientsForRecipe(int recipeId, SQLiteConnection connection)
 {
     using var selectIngredientsCommand   = connection.CreateCommand();
     selectIngredientsCommand.CommandText = "SELECT HopsIngredients.id, HopsIngredients.amount, HopsIngredients.time, HopsIngredients.type, HopsIngredients.form, Hops.name, Hops.alpha, HopsIngredients.use, Hops.notes, Hops.beta, Hops.hsi, Hops.origin, HopsIngredients.dryHopTime FROM HopsIngredients " +
                                            "JOIN HopsInRecipe ON HopsInRecipe.hopsIngredient = HopsIngredients.id AND HopsInRecipe.recipe = @recipeId " +
                                            "JOIN Hops ON Hops.id = HopsIngredients.hopsInfo";
     selectIngredientsCommand.Parameters.AddWithValue("recipeId", recipeId);
     using SQLiteDataReader reader = selectIngredientsCommand.ExecuteReader();
     while (reader.Read())
     {
         HopsCharacteristics characteristics = new HopsCharacteristics(reader.GetFloat(6), reader.GetFloat(9), reader.GetFloat(10));
         var    hopsInfo        = new Hops.Hops(reader.GetString(5), characteristics, reader.GetString(8), reader.GetString(11));
         string dryHopTimeValue = reader[12].ToString();
         int?   dryHopTime      = dryHopTimeValue.IsNullOrEmpty() ? null : (int?)int.Parse(dryHopTimeValue);
         yield return(new HopsIngredientDataModel(hopsInfo, reader.GetInt32(0))
         {
             Amount = reader.GetFloat(1),
             Time = reader.GetInt32(2),
             FlavorType = EnumConverter.Parse <HopsFlavorType>(reader[3].ToString()),
             Form = EnumConverter.Parse <HopsForm>(reader[4].ToString()),
             Use = EnumConverter.Parse <HopsUse>(reader.GetString(7)),
             DryHopTime = dryHopTime
         });
     }
 }
 public static Hops GetHops(XElement hopsEntry)
 {
     string name = GetNameFromRecord(hopsEntry);
     string origin = hopsEntry.Element("ORIGIN").Value;
     float alphaAcid = (float) Convert.ToDouble(hopsEntry.Element("ALPHA").Value);
     float betaAcid = (float) Convert.ToDouble(hopsEntry.Element("BETA").Value);
     string notes = GetNotesFromRecord(hopsEntry);
     float hsi = (float) Convert.ToDouble(hopsEntry.Element("HSI").Value);
     HopsCharacteristics hopsCharacteristics = new HopsCharacteristics(alphaAcid, betaAcid) { Hsi = hsi };
     return new Hops(name, hopsCharacteristics, notes, origin);
 }
Example #3
0
        public static IEnumerable <Hops.Hops> GetAvailableHopsVarieties(SQLiteConnection connection)
        {
            SQLiteCommand selectHopsCommand = connection.CreateCommand();

            selectHopsCommand.CommandText = "SELECT name, alpha, notes, beta, hsi, origin FROM Hops";
            using SQLiteDataReader reader = selectHopsCommand.ExecuteReader();
            while (reader.Read())
            {
                string name      = reader.GetString(0);
                float  alphaAcid = reader.GetFloat(1);
                string notes     = reader.GetString(2);
                float  betaAcid  = reader.GetFloat(3);
                float  hsi       = reader.GetFloat(4);
                string origin    = reader.GetString(5);

                var characteristics = new HopsCharacteristics(alphaAcid, betaAcid, hsi);
                yield return(new Hops.Hops(name, characteristics, notes, origin));
            }
        }
Example #4
0
        public static IEnumerable<Hops> GetAvailableHopsVarieties(SQLiteConnection connection)
        {
            SQLiteCommand selectHopsCommand = connection.CreateCommand();
            selectHopsCommand.CommandText = "SELECT name, alpha, notes, beta, hsi, origin FROM Hops";
            using (SQLiteDataReader reader = selectHopsCommand.ExecuteReader())
            {
                while (reader.Read())
                {
                    string name = reader.GetString(0);
                    float alphaAcid = reader.GetFloat(1);
                    string notes = reader.GetString(2);
                    float betaAcid = reader.GetFloat(3);
                    float hsi = reader.GetFloat(4);
                    string origin = reader.GetString(5);

                    HopsCharacteristics characteristics = new HopsCharacteristics(alphaAcid, betaAcid) { Hsi = hsi };
                    yield return new Hops(name, characteristics, notes, origin);
                }
            }
        }
Example #5
0
 internal static IEnumerable<HopsIngredientDataModel> GetHopsIngredientsForRecipe(int recipeId, SQLiteConnection connection)
 {
     using (SQLiteCommand selectIngredientsCommand = connection.CreateCommand())
     {
         selectIngredientsCommand.CommandText = "SELECT HopsIngredients.id, HopsIngredients.amount, HopsIngredients.time, HopsIngredients.type, HopsIngredients.form, Hops.name, Hops.alpha, HopsIngredients.use, Hops.notes, Hops.beta, Hops.hsi, Hops.origin, HopsIngredients.dryHopTime FROM HopsIngredients " +
             "JOIN HopsInRecipe ON HopsInRecipe.hopsIngredient = HopsIngredients.id AND HopsInRecipe.recipe = @recipeId " +
             "JOIN Hops ON Hops.id = HopsIngredients.hopsInfo";
         selectIngredientsCommand.Parameters.AddWithValue("recipeId", recipeId);
         using (SQLiteDataReader reader = selectIngredientsCommand.ExecuteReader())
         {
             while (reader.Read())
             {
                 HopsCharacteristics characteristics = new HopsCharacteristics(reader.GetFloat(6), reader.GetFloat(9)) { Hsi = reader.GetFloat(10) };
                 Hops hopsInfo = new Hops(reader.GetString(5), characteristics, reader.GetString(8), reader.GetString(11));
                 string dryHopTimeValue = reader[12].ToString();
                 int? dryHopTime = dryHopTimeValue.IsNullOrEmpty() ? null : (int?) int.Parse(dryHopTimeValue);
                 yield return new HopsIngredientDataModel(hopsInfo, reader.GetInt32(0))
                 {
                     Amount = reader.GetFloat(1),
                     Time = reader.GetInt32(2),
                     FlavorType = EnumConverter.Parse<HopsFlavorType>(reader[3].ToString()),
                     Form = EnumConverter.Parse<HopsForm>(reader[4].ToString()),
                     Use = EnumConverter.Parse<HopsUse>(reader.GetString(7)),
                     DryHopTime = dryHopTime
                 };
             }
         }
     }
 }