Exemple #1
0
        public static IngredientInRecepy operator+(IngredientInRecepy lhs, IngredientInRecepy rhs)
        {
            IngredientInRecepy result = new IngredientInRecepy(lhs);

            result.amount += conversionFactors[rhs.unit][lhs.unit] * rhs.amount;
            return(result);
        }
Exemple #2
0
 public IngredientInRecepy(IngredientInRecepy other)
 {
     this.id           = other.id;
     this.ingredientId = other.ingredientId;
     this.recepyId     = other.recepyId;
     this.amount       = other.amount;
     this.unit         = other.unit;
 }
Exemple #3
0
        public void AddIngredientInRecepy(IngredientInRecepy ingredientInRecepy)
        {
            if (connection == null)
            {
                return;
            }
            string        query   = String.Format(QUERY_ADD_INGREDIENT_IN_RECEPY, ingredientInRecepy.ingredientId, ingredientInRecepy.recepyId, ingredientInRecepy.amount, ingredientInRecepy.unit.ToString());
            SQLiteCommand command = new SQLiteCommand(query, connection);

            command.ExecuteNonQuery();
        }
        private void OnOkButtonClicked(object sender, RoutedEventArgs e)
        {
            Recepy recepy = new Recepy();

            recepy.description = recepyDescriptionTextBox.Text;
            recepy.name        = recepyNameTextBox.Text;
            foreach (var ingredient in ingredients)
            {
                Ingredient         i   = backendFacilities.GetIngredient(ingredient.name);
                IngredientInRecepy iir = new IngredientInRecepy();
                iir.amount       = ingredient.amount;
                iir.ingredientId = i != null ? i.id : -1;
                iir.unit         = ingredient.unit;
                recepy.ingredients.Add(iir);
            }
            backendFacilities.AddRecepy(recepy);
        }
Exemple #5
0
        public List <IngredientInRecepy> GetIngredientsInRecepy(int recepyId)
        {
            if (connection == null)
            {
                return(null);
            }
            string                    query               = String.Format(QUERY_GET_INGREDIENTS_IN_RECEPY, recepyId.ToString());
            SQLiteCommand             command             = new SQLiteCommand(query, connection);
            SQLiteDataReader          reader              = command.ExecuteReader();
            List <IngredientInRecepy> ingredientsInRecepy = new List <IngredientInRecepy>();

            while (reader.Read())
            {
                IngredientInRecepy ingredient = new IngredientInRecepy();
                ingredient.amount       = (float)reader["Amount"];
                ingredient.id           = (int)reader["Id"];
                ingredient.ingredientId = (int)reader["IngredientId"];
                ingredient.recepyId     = (int)reader["RecepyId"];
                ingredient.unit         = (Unit)reader["Unit"];

                ingredientsInRecepy.Add(ingredient);
            }
            return(ingredientsInRecepy);
        }