예제 #1
0
        private static void runEfContext()
        {
            Database.SetInitializer(new DropCreateDatabaseIfModelChanges <CookbookMfContext>());

            using (var context = new CookbookMfContext())
            {
                seed(context);
            }
        }
예제 #2
0
        public DefaultEfRepository(CookbookMfContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            m_context = context;
        }
예제 #3
0
        private static void seed(CookbookMfContext context)
        {
            const string dummyRecipeText =
                @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vitae felis sapien. Sed a faucibus lacus.";


            var standardCategory    = new RecipeCategory("Všední jídla");
            var specilitiesCategory = new RecipeCategory("Specialitky");

            context.RecipeCategories.Add(standardCategory);

            context.RecipeCategories.Add(specilitiesCategory);


            context.Recipes.Add(new Recipe
            {
                Category    = standardCategory,
                Name        = "Michaná vajíčka",
                Description = dummyRecipeText
            });

            context.Recipes.Add(new Recipe
            {
                Category    = standardCategory,
                Name        = "Párky",
                Description = dummyRecipeText
            });

            context.Recipes.Add(new Recipe
            {
                Category    = specilitiesCategory,
                Name        = "Lahůdkové párky",
                Description = dummyRecipeText
            });


            context.Recipes.Add(new Recipe
            {
                Category    = specilitiesCategory,
                Name        = "Babicova pizza",
                Description = dummyRecipeText
            });


            context.Recipes.Add(new Recipe
            {
                Category    = specilitiesCategory,
                Name        = "Kuře Vindaloo",
                Description = dummyRecipeText
            });

            context.SaveChanges();
        }
예제 #4
0
        private static void initServices()
        {
            //Polovičaté mapování abstrakce na implementaci

            var context = new CookbookMfContext();

            SimpleServiceRepository.Instance.RegisterService <IRepository <Recipe> >(new DefaultEfRepository <Recipe>(context));
            SimpleServiceRepository.Instance.RegisterService <IRepository <RecipeCategory> >(
                new DefaultEfRepository
                <RecipeCategory>(context));
            SimpleServiceRepository.Instance.RegisterService <IExporter>(new WordExporter());
            SimpleServiceRepository.Instance.RegisterService(new RecipeUIFacade());
        }
 protected DefaultRepositoryHolder()
 {
     m_context                  = new CookbookMfContext();
     m_recipeRepository         = new DefaultEfRepository <Recipe>(m_context);
     m_recipeCategoryRepository = new DefaultEfRepository <RecipeCategory>(m_context);
 }