Beispiel #1
0
 public Ingredient(IngredientBase ingredientBase, bool paramOptionPlus)
 {
     this.Categorie          = ingredientBase.Categorie;
     this.Nom                = ingredientBase.Nom;
     this.OptionPlus         = ingredientBase.OptionPlus;
     this.OptionPlusPossible = ingredientBase.OptionPlusPossible;
     this.QuantitesPoints    = ingredientBase.QuantitesPoints;
     this.UtiliserOptionPlus = paramOptionPlus;
 }
Beispiel #2
0
        public void AddIngredient(IngredientBase ingredientBase, bool optionPlus)
        {
            List <Ingredient> result = Ingredients.Where(x => x.Nom == ingredientBase.Nom).ToList();

            if (result.Count == 0)
            {
                Ingredients.Add(new WetProPointData.Ingredient(ingredientBase, optionPlus));
            }
            else
            {
                result[0].Quantite += 1;
            }

            Ingredients = new List <Ingredient>(Ingredients);
        }
Beispiel #3
0
        private void Scan(ExcelWorksheet worksheet, int col, StreamWriter databaseFileXML, ref Categorie currentCat, ListeIngredients ingredients, ListeCategories categories, ref int indexCategorie, ref int indexIngredient)
        {
            object line  = null;
            int    index = 1;

            IngredientBase ingredient = null;

            while ((line = worksheet.Cells[index, col].Value) != null)
            {
                string col1 = worksheet.Cells[index, col].Value.ToString();

                object col2Obj = null;

                if ((col2Obj = worksheet.Cells[index++, col + 1].Value) != null)
                {
                    string col2 = col2Obj.ToString();

                    if (col2.Trim().CompareTo("CAT") != -1)
                    {
                        currentCat = new Categorie()
                        {
                            Id = indexCategorie++, Nom = col1.Trim()
                        };
                        categories.Categories.Add(currentCat);
                        //databaseFileXML.WriteLine(currentCat.Nom);
                    }
                    else
                    {
                        string nom = col1.ToString();
                        if (nom.Contains("Option Plus"))
                        {
                            // Option plus
                            // Récupérer l'ingrédient précédent !
                            // Lui ajouter l'option plus
                            if (ingredient != null)
                            {
                                ingredient.OptionPlus         = int.Parse(col2.ToString().Trim());
                                ingredient.OptionPlusPossible = true;
                            }
                        }
                        else
                        {
                            var nomSplit = col1.ToString().Split(new[] { ',' }, 2);

                            ingredient = ingredients.Ingredients.FirstOrDefault(s => s.Nom == nomSplit[0].Trim());

                            if (ingredient == null)
                            {
                                ingredient = new IngredientBase()
                                {
                                    Id = indexIngredient++, Nom = nomSplit[0].Trim(), Categorie = currentCat
                                };
                                ingredients.Ingredients.Add(ingredient);
                            }

                            ingredient.QuantitesPoints.Add(new QuantitePoint()
                            {
                                Quantite = (nomSplit.GetLength(0) > 1 ? nomSplit[1].Trim() : ""), PointParUnite = int.Parse(col2.ToString().Trim())
                            });
                            //databaseFileXML.WriteLine("\t" + ingredient.Nom + " ," + ingredient.PointParUnite + (ingredient.OptionPlusPossible?" (Option plus:" + ingredient.OptionPlus + ")":""));
                        }
                    }
                }
            }
        }