Example #1
0
 public Yeast(string name, YeastCharacteristics characteristics, string notes, string laboratory, string productId)
     : base(name, notes)
 {
     m_characteristics = characteristics;
     m_laboratory = laboratory;
     m_productId = productId;
 }
Example #2
0
        public static IEnumerable <Yeast.Yeast> GetAvailableYeasts(SQLiteConnection connection)
        {
            var selectYeastCommand = connection.CreateCommand();

            selectYeastCommand.CommandText = "SELECT name, type, form, laboratory, productId, minTemperature, maxTemperature, flocculation, attenuation, notes FROM Yeasts";
            using var reader = selectYeastCommand.ExecuteReader();
            while (reader.Read())
            {
                string name           = reader.GetString(0);
                string type           = reader.GetString(1);
                string form           = reader.GetString(2);
                string laboratory     = reader.GetString(3);
                string productId      = reader.GetString(4);
                float  minTemperature = reader.GetFloat(5);
                float  maxTemperature = reader.GetFloat(6);
                string flocculation   = reader.GetString(7);
                float  attenuation    = reader.GetFloat(8);
                string notes          = reader.GetString(9);

                var characteristics = new YeastCharacteristics(type, flocculation, form)
                {
                    Attenuation    = attenuation,
                    MinTemperature = minTemperature,
                    MaxTemperature = maxTemperature
                };
                yield return(new Yeast.Yeast(name, characteristics, notes, laboratory, productId));
            }
        }
Example #3
0
 internal static YeastIngredientDataModel GetYeastIngredientForRecipe(int recipeId, SQLiteConnection connection)
 {
     using var selectIngredientsCommand   = connection.CreateCommand();
     selectIngredientsCommand.CommandText = "SELECT YeastIngredients.id, YeastIngredients.weight, YeastIngredients.volume, Yeasts.id, Yeasts.name, Yeasts.type, Yeasts.form, Yeasts.laboratory, Yeasts.productId, Yeasts.minTemperature, Yeasts.maxTemperature, Yeasts.flocculation, Yeasts.attenuation, Yeasts.notes FROM YeastIngredients " +
                                            "JOIN Recipes ON Recipes.yeastIngredientInfo = YeastIngredients.id AND Recipes.id = @recipeId " +
                                            "JOIN Yeasts ON Yeasts.id = YeastIngredients.yeastInfo " +
                                            "LIMIT 1";
     selectIngredientsCommand.Parameters.AddWithValue("recipeId", recipeId);
     using var reader = selectIngredientsCommand.ExecuteReader();
     while (reader.Read())
     {
         var characteristics = new YeastCharacteristics(reader.GetString(5), reader.GetString(11), reader.GetString(6))
         {
             Attenuation    = reader.GetFloat(12),
             MinTemperature = reader.GetFloat(9),
             MaxTemperature = reader.GetFloat(10)
         };
         var yeastInfo = new Yeast.Yeast(reader.GetString(4), characteristics, reader.GetString(13), reader.GetString(7), reader.GetString(8));
         return(new YeastIngredientDataModel(yeastInfo, reader.GetInt32(0))
         {
             Volume = reader.GetFloat(2), Weight = reader.GetFloat(1)
         });
     }
     return(null);
 }
Example #4
0
        public static IEnumerable<Yeast> GetAvailableYeasts(SQLiteConnection connection)
        {
            SQLiteCommand selectYeastCommand = connection.CreateCommand();
            selectYeastCommand.CommandText = "SELECT name, type, form, laboratory, productId, minTemperature, maxTemperature, flocculation, attenuation, notes FROM Yeasts";
            using (SQLiteDataReader reader = selectYeastCommand.ExecuteReader())
            {
                while (reader.Read())
                {
                    string name = reader.GetString(0);
                    string type = reader.GetString(1);
                    string form = reader.GetString(2);
                    string laboratory = reader.GetString(3);
                    string productId = reader.GetString(4);
                    float minTemperature = reader.GetFloat(5);
                    float maxTemperature = reader.GetFloat(6);
                    string flocculation = reader.GetString(7);
                    float attenuation = reader.GetFloat(8);
                    string notes = reader.GetString(9);

                    YeastCharacteristics characteristics = new YeastCharacteristics(type, flocculation, form)
                    {
                        Attenuation = attenuation,
                        MinTemperature = minTemperature,
                        MaxTemperature = maxTemperature
                    };
                    yield return new Yeast(name, characteristics, notes, laboratory, productId);
                }
            }
        }
        public static Yeast.Yeast GetYeast(XElement yeastEntry)
        {
            var name           = GetNameFromRecord(yeastEntry);
            var type           = EnumConverter.Parse <YeastType>(yeastEntry.GetChildElementValue("TYPE"));
            var form           = EnumConverter.Parse <YeastForm>(yeastEntry.GetChildElementValue("FORM"));
            var laboratory     = yeastEntry.GetChildElementValue("LABORATORY");
            var productId      = yeastEntry.GetChildElementValue("PRODUCT_ID");
            var minTemperature = Convert.ToSingle(yeastEntry.GetChildElementValue("MIN_TEMPERATURE"));
            var maxTemperature = Convert.ToSingle(yeastEntry.GetChildElementValue("MAX_TEMPERATURE"));
            var flocculation   = EnumConverter.Parse <Flocculation>(yeastEntry.GetChildElementValue("FLOCCULATION"));
            var attenuation    = Convert.ToSingle(yeastEntry.GetChildElementValue("ATTENUATION"));
            var notes          = GetNotesFromRecord(yeastEntry);

            var characteristics = new YeastCharacteristics(type, flocculation, form, minTemperature, maxTemperature, attenuation);

            return(new Yeast.Yeast(name, characteristics, notes, laboratory, productId));
        }
        public static Yeast GetYeast(XElement yeastEntry)
        {
            string name = GetNameFromRecord(yeastEntry);
            string type = yeastEntry.Element("TYPE").Value;
            string form = yeastEntry.Element("FORM").Value;
            string laboratory = yeastEntry.Element("LABORATORY").Value;
            string productId = yeastEntry.Element("PRODUCT_ID").Value;
            float minTemperature = (float) Convert.ToDouble(yeastEntry.Element("MIN_TEMPERATURE").Value);
            float maxTemperature = (float) Convert.ToDouble(yeastEntry.Element("MAX_TEMPERATURE").Value);
            string flocculation = yeastEntry.Element("FLOCCULATION").Value;
            float attenuation = (float) Convert.ToDouble(yeastEntry.Element("ATTENUATION").Value);
            string notes = GetNotesFromRecord(yeastEntry);

            YeastCharacteristics characteristics = new YeastCharacteristics(type, flocculation, form) { Attenuation = attenuation, MinTemperature = minTemperature, MaxTemperature = maxTemperature };
            return new Yeast(name, characteristics, notes, laboratory, productId);
        }
Example #7
0
 internal static YeastIngredientDataModel GetYeastIngredientForRecipe(int recipeId, SQLiteConnection connection)
 {
     using (SQLiteCommand selectIngredientsCommand = connection.CreateCommand())
     {
         selectIngredientsCommand.CommandText = "SELECT YeastIngredients.id, YeastIngredients.weight, YeastIngredients.volume, Yeasts.id, Yeasts.name, Yeasts.type, Yeasts.form, Yeasts.laboratory, Yeasts.productId, Yeasts.minTemperature, Yeasts.maxTemperature, Yeasts.flocculation, Yeasts.attenuation, Yeasts.notes FROM YeastIngredients " +
             "JOIN Recipes ON Recipes.yeastIngredientInfo = YeastIngredients.id AND Recipes.id = @recipeId " +
             "JOIN Yeasts ON Yeasts.id = YeastIngredients.yeastInfo " +
             "LIMIT 1";
         selectIngredientsCommand.Parameters.AddWithValue("recipeId", recipeId);
         using (SQLiteDataReader reader = selectIngredientsCommand.ExecuteReader())
         {
             while (reader.Read())
             {
                 YeastCharacteristics characteristics = new YeastCharacteristics(reader.GetString(5), reader.GetString(11), reader.GetString(6))
                 {
                     Attenuation = reader.GetFloat(12),
                     MinTemperature = reader.GetFloat(9),
                     MaxTemperature = reader.GetFloat(10)
                 };
                 Yeast yeastInfo = new Yeast(reader.GetString(4), characteristics, reader.GetString(13), reader.GetString(7), reader.GetString(8));
                 return new YeastIngredientDataModel(yeastInfo, reader.GetInt32(0)) { Volume = reader.GetFloat(2), Weight = reader.GetFloat(1) };
             }
         }
     }
     return null;
 }