예제 #1
0
        static List <Recepie> Shuffle(List <Recepie> array)
        {
            Random random = new Random();
            int    n      = array.Count;

            for (int i = 0; i < array.Count; i++)
            {
                int     r = i + random.Next(n - i);
                Recepie t = array[r];
                array[r] = array[i];
                array[i] = t;
            }
            return(array);
        }
예제 #2
0
        private static void InsertRecepieIntoDatabase(string name, List <Ingredient> ingredients, List <Category> categories, NHibernate.ISession session)
        {
            Recepie recepie = new Recepie();

            recepie.Name = name;

            foreach (Ingredient ingredient in ingredients)
            {
                recepie.AddIngredient(ingredient);

                session.Save(ingredient);
            }

            foreach (Category category in categories)
            {
                recepie.AddCategory(category);
                category.AddRecepie(recepie);
                session.Save(category);
            }
            session.Save(recepie);
        }
예제 #3
0
        private static List <Category> GetCategoryByRecepie(Recepie recepie, NHibernate.ISession session)
        {
            var categories = session.Query <Category>().ToList();

            return(categories);
        }
예제 #4
0
        private static List <Ingredient> GetIngredientsByRecepie(Recepie recepie, NHibernate.ISession session)
        {
            var ingredients = session.Query <Ingredient>().ToList();

            return(ingredients);
        }
예제 #5
0
 public virtual void AddRecepie(Recepie recepie)
 {
     Recepies.Add(recepie);
     recepie.Ingredients.Add(this);
 }
예제 #6
0
 public virtual void AddRecepie(Recepie recepie)
 {
     Recepies.Add(recepie);
     recepie.Categories.Add(this);
 }