コード例 #1
0
        private Controller Create(Type type, ControllerContext context)
        {
            MusicZoneDbContext efDbContext = new MusicZoneDbContext(this.connectionString);

            // Similar as context.HttpContext.Response.RegisterForDispose method
            TrackDisposable(context, efDbContext);

            Scope scope = new Scope();

            TrackDisposable(context, scope);

            // can be optimized - lazy loading?
            //IUserService userService = (IUserService)this.accessor.HttpContext
            //   .RequestServices
            //   .GetService(typeof(IUserService));

            //ISignInService signInService = (ISignInService)this.accessor.HttpContext
            //    .RequestServices
            //    .GetService(typeof(ISignInService));

            //should be in singleton scope?
            //IEmailSenderService emailSender = new EmailSenderService(this.emailSettings);

            Controller controller = this.CheckAreasControllers(type, scope);

            if (controller is null)
            {
                controller = this.CheckNormalControllers(type, scope);
            }

            return(controller);
        }
コード例 #2
0
        public void DummyTest1()
        {
            MusicZoneDbContext context = new MusicZoneDbContext(TestsInitializer.ConnectionString);
            bool any = context.Users.Any();

            Assert.IsFalse(any);
        }
コード例 #3
0
ファイル: EfRepository.cs プロジェクト: vncpetrov/Mp3Music
        protected EfRepository(MusicZoneDbContext efDbContext)
        {
            if (efDbContext is null)
            {
                throw new ArgumentNullException(nameof(efDbContext));
            }

            this.context = efDbContext;
            this.dbSet   = efDbContext.Set <TEntity>();
        }
コード例 #4
0
        public static IWebHost MigrateDatabase(this IWebHost webHost)
        {
            using (IServiceScope scope = webHost.Services.CreateScope())
            {
                IServiceProvider services = scope.ServiceProvider;

                string connectionString = services.GetService <IConfiguration>()
                                          .GetConnectionString(ConnectionStringSectionName);

                MusicZoneDbContext efDbContext = new MusicZoneDbContext(connectionString);
                //efDbContext.Database.EnsureDeleted();
                EfDbContextUtils.UseDatabaseMigration(efDbContext);
                //efDbContext.Database.Migrate();
            }

            return(webHost);
        }
コード例 #5
0
    public void AssemblyInit()
    {
        string             projectPath   = AppDomain.CurrentDomain.BaseDirectory.Split(new string[] { @"bin\" }, StringSplitOptions.None)[0];
        IConfigurationRoot configuration = new ConfigurationBuilder()
                                           .SetBasePath(projectPath)
                                           .AddJsonFile("appsettings.json")
                                           .Build();

        string connectionString =
            configuration.GetConnectionString(ConnectionStringSectionName);

        TestsInitializer.ConnectionString = connectionString;

        MusicZoneDbContext context = new MusicZoneDbContext(connectionString);

        EfDbContextUtils.UseDatabaseMigration(context);

        TestsInitializer.EmailSettings = configuration.GetSection("EmailSettings").Get <EmailSettings>();
    }
コード例 #6
0
        public static async Task <IWebHost> SeedDatabase(this IWebHost webHost)
        {
            using (IServiceScope scope = webHost.Services.CreateScope())
            {
                IServiceProvider services = scope.ServiceProvider;

                string connectionString = services.GetService <IConfiguration>()
                                          .GetConnectionString(ConnectionStringSectionName);

                MusicZoneDbContext efDbContext = new MusicZoneDbContext(connectionString);

                IUserService userService = services.GetService <IUserService>();
                IRoleService roleService = services.GetService <IRoleService>();

                //DataSeeder.Seed(userService, roleService);

                ICommandService <OnStartupNullObject> startupCommandServices =
                    new CompositeOnStartupCommandService(
                        new ICommandService <OnStartupNullObject>[]
                {
                    new RegisterPermissionsCommandService(
                        new PermissionEfRepository(efDbContext),
                        efDbContext),
                    new RegisterRolesCommandService(roleService),
                    new RegisterAdministratorCommandService(userService),
                    new AddRolesPermissionsCommandService(
                        new RoleEfRepository(efDbContext),
                        new PermissionEfRepository(efDbContext),
                        efDbContext)
                });

                await startupCommandServices.ExecuteAsync(new OnStartupNullObject());
            }

            return(webHost);
        }
コード例 #7
0
 public UserEfRepository(MusicZoneDbContext context)
     : base(context)
 {
 }
コード例 #8
0
 public AuditEntryEfRepository(MusicZoneDbContext context)
     : base(context)
 {
 }
コード例 #9
0
 public RoleEfRepository(MusicZoneDbContext context)
     : base(context)
 {
 }
コード例 #10
0
 public UnhandledExceptionEntryEfRepository(MusicZoneDbContext context)
     : base(context)
 {
 }
コード例 #11
0
 public PerformanceEntryEfRepository(MusicZoneDbContext efDbContext)
     : base(efDbContext)
 {
 }
コード例 #12
0
 public PermissionEfRepository(MusicZoneDbContext context)
     : base(context)
 {
 }
コード例 #13
0
 public SongEfRepository(MusicZoneDbContext context)
     : base(context)
 {
 }