Exemplo n.º 1
0
 public void InsertBatch(DateTime date, string recipeName, int preparatedBatches)
 {
     recipeQuery.UserRecipes().ForEach(x =>
     {
         if (recipeName == x.RecipeName)
         {
             batchQuery.InsertBatch(date, x.GetID(), preparatedBatches);
         }
     });
 }
        private void InsertBatch()
        {
            RecipeQuery recipe = new RecipeQuery();

            string[] listOfRecipeNames    = new string[10];
            string[] listOfPreparedBaches = new string[10];
            int      listIndex            = 0;

            Console.WriteLine("----Dodaj Zesatw----");
            Console.Write("Wpisz datę: ");
            string date = Console.ReadLine();

            DateTime date1 = StringToDateConverter(date);

            Console.WriteLine("Dostępne Receptury: ");
            ListOfRecipeNames(recipe);

            //Loop where you can write how meny batches where prepared
            while (true)
            {
                Console.Write("Nazwa receptury: ");
                string nameOfRecipe = Console.ReadLine();
                Console.Write("Ile Zestawów: ");
                string howMeny = Console.ReadLine();

                listOfRecipeNames[listIndex]    = nameOfRecipe;
                listOfPreparedBaches[listIndex] = howMeny;

                listIndex++;
                string com = Console.ReadLine();
                if (com == "q")
                {
                    break;
                }

                if (com == "r")
                {
                    ListOfRecipeNames(recipe);
                }
            }

            //Insert batches to DB
            for (int j = 0; j < listIndex; j++)
            {
                recipe.UserRecipes().ForEach(x =>
                {
                    if (listOfRecipeNames[j] == x.RecipeName)
                    {
                        query.InsertBatch(date1, x.GetID(), int.Parse(listOfPreparedBaches[j]));
                    }
                });
            }
        }