示例#1
0
        public void Migrations_CheckSeededDataWorkingForCategoriesTable()
        {
            // All contexts that share the same service provider will share the same InMemory database
            var options = CreateNewContextOptions();

            // Run the test against one instance of the context
            using (var context = new JournalContext(options))
            {
                var logger = new Mock <ILogger>();

                // Seed the database with data
                SeedDataExtensions.SeedData(context, logger.Object);
                var categoriesExist = context.Categories.AnyAsync().Result;

                Assert.IsTrue(categoriesExist);
            }
        }
示例#2
0
        private static IGstoreDb NewRepository(string userName)
        {
            //get setting for repositorysource and create repository
            switch (RepositoryProvider())
            {
            case RepositoryProviderEnum.EntityFrameworkCodeFirstProvider:
                return(new EntityFrameworkCodeFirstProvider.GStoreEFDbContext(userName));

            case RepositoryProviderEnum.ListProvider:
                //note ListProvider uses a single static list, no copies or real separate contexts
                _listDb = new ListProvider.ListContext();
                SeedDataExtensions.AddSeedData(_listDb);
                return(_listDb);

            //allow for other repositories, perhaps by class or project name; and config mapping here
            //Example: pull in a provider that takes some lists, some ef, some web services, some whoknowswhats
            default:
                break;
            }

            throw new ApplicationException("Unable to create repository:" + RepositoryProvider().ToString());
        }
示例#3
0
        public void Configure
        (
            IApplicationBuilder app,
            IWebHostEnvironment env,
            UserManager <AppUser> userManager
        )
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            SeedDataExtensions.SeedUsers(userManager);
            //app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseMiddleware <Trial>();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");

                endpoints.MapHub <ServerStatusHub>("/server-status-hub");
                endpoints.MapHub <StreamStatusHub>("/stream-status-hub");
                endpoints.MapHub <MovieStatusHub>("/movie-status-hub");
                endpoints.MapHub <ChannelStatusHub>("/channel-status-hub");
                endpoints.MapHub <DirectoryBrowserHub>("/directory-browser-hub");
            });
        }
 protected override void Seed(GStoreEFDbContext context)
 {
     SeedDataExtensions.AddSeedData(context.GStoreDb);
     base.Seed(context);
 }
示例#5
0
 protected override void Seed(EntityFrameworkCodeFirstProvider.GStoreEFDbContext context)
 {
     SeedDataExtensions.AddSeedData(context);
 }
示例#6
0
 public static void SeedDatabase(this IGstoreDb db, bool force = false)
 {
     SeedDataExtensions.AddSeedData(db, force);
 }
示例#7
0
 public static Page AutoCreateHomePage(this IGstoreDb db, HttpRequestBase request, StoreFrontConfiguration storeFrontConfig, GStoreData.ControllerBase.BaseController baseController)
 {
     return(SeedDataExtensions.CreateAutoHomePage(db, request, storeFrontConfig, baseController));
 }
示例#8
0
 /// <summary>
 /// Returns the best guess for the store front to activate for auto-map
 /// </summary>
 /// <param name="db"></param>
 /// <returns></returns>
 public static StoreFrontConfiguration AutoMapStoreFrontConfigTarget(this IGstoreDb db)
 {
     return(SeedDataExtensions.SeedAutoMapStoreFrontConfigBestGuess(db));
 }
示例#9
0
 /// <summary>
 /// Returns the best guess for the user profile to use auto-map
 /// </summary>
 /// <param name="db"></param>
 /// <returns></returns>
 public static UserProfile AutoMapUserProfileTarget(this IGstoreDb db)
 {
     return(SeedDataExtensions.SeedAutoMapUserBestGuess(db));
 }
示例#10
0
 public static StoreBinding AutoMapBindingToCatchAll(this IGstoreDb db, GStoreData.ControllerBase.BaseController baseController)
 {
     return(SeedDataExtensions.CreatAutoMapStoreBindingToCatchAll(db, baseController));
 }