/// <summary> /// Add localization module /// </summary> /// <typeparam name="TContext"></typeparam> /// <param name="services"></param> /// <param name="options"></param> /// <returns></returns> public static IServiceCollection AddLocalizationModuleStorage <TContext>(this IServiceCollection services, Action <DbContextOptionsBuilder> options) where TContext : DbContext, ILocalizationContext { services.AddScopedContextFactory <ILocalizationContext, TContext>(); services.RegisterAuditFor <TContext>("Localization module"); SystemEvents.Database.OnAllMigrate += (sender, args) => { GearApplication.GetHost <IWebHost>().MigrateDbContext <TContext>(); }; return(services); }
/// <summary> /// Register commerce storage /// </summary> /// <typeparam name="TContext"></typeparam> /// <param name="services"></param> /// <param name="storageOptions"></param> /// <returns></returns> public static IServiceCollection RegisterCommerceStorage <TContext>(this IServiceCollection services, Action <DbContextOptionsBuilder> storageOptions) where TContext : DbContext, ICommerceContext { services.AddDbContext <TContext>(storageOptions); SystemEvents.Database.OnAllMigrate += (sender, args) => { GearApplication.GetHost <IWebHost>().MigrateDbContext <TContext>(); }; return(services); }
/// <summary> /// Register storage /// </summary> /// <typeparam name="TTaskManagerContext"></typeparam> /// <param name="services"></param> /// <param name="options"></param> /// <returns></returns> public static IServiceCollection AddTaskModuleStorage <TTaskManagerContext>(this IServiceCollection services, Action <DbContextOptionsBuilder> options) where TTaskManagerContext : DbContext, ITaskManagerContext { services.AddScopedContextFactory <ITaskManagerContext, TTaskManagerContext>(); services.AddDbContext <TTaskManagerContext>(options, ServiceLifetime.Transient); services.RegisterAuditFor <ITaskManagerContext>($"{nameof(TaskManager)} module"); SystemEvents.Database.OnAllMigrate += (sender, args) => { GearApplication.GetHost <IWebHost>().MigrateDbContext <TTaskManagerContext>(); }; return(services); }
/// <summary> /// Add module storage /// </summary> /// <typeparam name="TContext"></typeparam> /// <param name="services"></param> /// <param name="options"></param> /// <returns></returns> public static IServiceCollection AddProcessesModuleStorage <TContext>(this IServiceCollection services, Action <DbContextOptionsBuilder> options) where TContext : DbContext, IProcessesDbContext { Arg.NotNull(options, nameof(AddProcessesModuleStorage)); services.AddDbContext <TContext>(options); services.RegisterAuditFor <IProcessesDbContext>("Processes module"); SystemEvents.Database.OnAllMigrate += (sender, args) => { GearApplication.GetHost <IWebHost>().MigrateDbContext <TContext>(); }; return(services); }
/// <summary> /// Add country module storage /// </summary> /// <typeparam name="TContext"></typeparam> /// <param name="services"></param> /// <param name="options"></param> /// <returns></returns> public static IServiceCollection AddCountryModuleStorage <TContext>(this IServiceCollection services, Action <DbContextOptionsBuilder> options) where TContext : DbContext, ICountryContext { services.AddTransient <ICountryContext, TContext>(); services.AddDbContext <TContext>(options); services.RegisterAuditFor <TContext>("Countries module"); SystemEvents.Database.OnAllMigrate += (sender, args) => { GearApplication.GetHost <IWebHost>().MigrateDbContext <TContext>(); }; return(services); }
/// <summary> /// Add identity server /// </summary> /// <param name="services"></param> /// <param name="configuration"></param> /// <returns></returns> public static IServiceCollection AddIdentityClientsModule <TUser, TConfiguration, TPersisted, TClientsConfiguration>(this IServiceCollection services, IConfiguration configuration) where TClientsConfiguration : DefaultClientsConfigurator where TUser : GearUser where TConfiguration : ConfigurationDbContext <TConfiguration>, IClientsContext where TPersisted : PersistedGrantDbContext <TPersisted>, IClientsPersistedGrantContext { var configurator = Activator.CreateInstance <TClientsConfiguration>(); var migrationsAssembly = typeof(TConfiguration).Assembly.GetName().Name; void DbOptions(DbContextOptionsBuilder builder) => builder.RegisterIdentityStorage(configuration, migrationsAssembly); services.AddIdentityServer(options => { options.Authentication.CookieLifetime = TimeSpan.FromHours(2); options.Events.RaiseSuccessEvents = true; options.Events.RaiseFailureEvents = true; options.Events.RaiseErrorEvents = true; }) .AddCertificate() .AddAspNetIdentity <TUser>() .AddConfigurationStore <TConfiguration>(options => { options.DefaultSchema = IdentityConfig.DEFAULT_SCHEMA; options.ConfigureDbContext = DbOptions; }) .AddOperationalStore <TPersisted>(options => { options.DefaultSchema = IdentityConfig.DEFAULT_SCHEMA; options.ConfigureDbContext = DbOptions; options.EnableTokenCleanup = true; options.TokenCleanupInterval = 30; }) .AddResourceStore <CustomResourceStore>() .AddClientStore <CustomClientStore>(); //.AddResourceOwnerValidator<CustomResourceOwnerPasswordValidator>(); services.AddTransient <ICorsPolicyService, CustomCorsPolicyService>(); services.AddGearSingleton <IClientsContext, TConfiguration>(); services.AddGearSingleton <IClientsPersistedGrantContext, TPersisted>(); SystemEvents.Database.OnAllMigrate += (sender, args) => { GearApplication.GetHost <IWebHost>() .MigrateDbContext <TPersisted>() .MigrateDbContext <TConfiguration>((context, servicesProvider) => { ClientsSeeder.SeedAsync(servicesProvider, configurator) .Wait(); }); }; return(services); }
/// <summary> /// Register module storage /// </summary> /// <typeparam name="TContext"></typeparam> /// <param name="services"></param> /// <param name="options"></param> /// <returns></returns> public static INotificationServiceCollection AddNotificationSubscriptionModuleStorage <TContext>(this INotificationServiceCollection services, Action <DbContextOptionsBuilder> options) where TContext : DbContext, INotificationSubscriptionsDbContext { Arg.NotNull(services, nameof(AddNotificationSubscriptionModuleStorage)); services.Services.AddDbContext <TContext>(options); services.Services.AddScopedContextFactory <INotificationSubscriptionsDbContext, TContext>(); services.Services.RegisterAuditFor <INotificationSubscriptionsDbContext>($"{nameof(Notification)} module"); SystemEvents.Database.OnAllMigrate += (sender, args) => { GearApplication.GetHost <IWebHost>().MigrateDbContext <TContext>(); }; return(services); }
public static IServiceCollection AddFileBoxModuleStorage <TFileBoxContext>(this IServiceCollection services, Action <DbContextOptionsBuilder> options, IConfiguration configuration) where TFileBoxContext : DbContext, IFileBoxContext { services.AddScopedContextFactory <IFileBoxContext, TFileBoxContext>(); services.AddDbContext <TFileBoxContext>(options, ServiceLifetime.Transient); services.RegisterAuditFor <IFileBoxContext>("File box module"); services.ConfigureWritable <List <FileBoxSettingsViewModel> >(configuration.GetSection("FileBoxSettings")); SystemEvents.Database.OnAllMigrate += (sender, args) => { GearApplication.GetHost <IWebHost>().MigrateDbContext <TFileBoxContext>(); }; return(services); }
/// <summary> /// Add dashboard module storage /// </summary> /// <typeparam name="TDbContext"></typeparam> /// <param name="configuration"></param> /// <param name="options"></param> /// <returns></returns> public static IDashboardServiceCollection AddDashboardModuleStorage <TDbContext>( this IDashboardServiceCollection configuration, Action <DbContextOptionsBuilder> options) where TDbContext : DbContext, IDashboardDbContext { Arg.NotNull(configuration.Services, nameof(AddDashboardModuleStorage)); configuration.Services.AddDbContext <TDbContext>(options, ServiceLifetime.Transient); configuration.Services.AddScopedContextFactory <IDashboardDbContext, TDbContext>(); SystemEvents.Database.OnMigrate += (sender, args) => { GearApplication.GetHost <IWebHost>().MigrateDbContext <TDbContext>(); }; return(configuration); }
/// <summary> /// Add Crm storage /// </summary> /// <typeparam name="TDbContext"></typeparam> /// <param name="services"></param> /// <param name="options"></param> /// <returns></returns> public static IServiceCollection AddCrmModuleStorage <TDbContext>( this IServiceCollection services, Action <DbContextOptionsBuilder> options) where TDbContext : DbContext, ICrmContext { Arg.NotNull(services, nameof(AddCrmModuleStorage)); services.AddDbContext <TDbContext>(options, ServiceLifetime.Transient); services.AddGearTransient <ICrmContext, TDbContext>(); SystemEvents.Database.OnMigrate += (sender, args) => { GearApplication.GetHost <IWebHost>().MigrateDbContext <TDbContext>(); }; return(services); }
/// <summary> /// Register module storage /// </summary> /// <param name="services"></param> /// <param name="options"></param> /// <returns></returns> public static IServiceCollection AddDynamicReportModuleStorage <TReportContext>(this IServiceCollection services, Action <DbContextOptionsBuilder> options) where TReportContext : DbContext, IReportContext { services.AddDbContext <TReportContext>(options); services.AddScopedContextFactory <IReportContext, TReportContext>(); services.RegisterAuditFor <IReportContext>($"{nameof(Report)} module"); SystemEvents.Database.OnAllMigrate += (sender, args) => { GearApplication.GetHost <IWebHost>().MigrateDbContext <TReportContext>(); }; return(services); }
/// <summary> /// Add user activity module storage /// </summary> /// <typeparam name="TContext"></typeparam> /// <param name="services"></param> /// <param name="options"></param> /// <returns></returns> public static IServiceCollection AddUserActivityModuleStorage <TContext>(this IServiceCollection services, Action <DbContextOptionsBuilder> options) where TContext : DbContext, IActivityContext { services.AddDbContext <TContext>(options); services.AddScopedContextFactory <IActivityContext, TContext>(); SystemEvents.Database.OnAllMigrate += (sender, args) => { GearApplication.GetHost <IWebHost>().MigrateDbContext <TContext>(); }; return(services); }
/// <summary> /// Add module storage /// </summary> /// <typeparam name="TPageContext"></typeparam> /// <param name="services"></param> /// <param name="options"></param> /// <returns></returns> public static IServiceCollection AddPageModuleStorage <TPageContext>(this IServiceCollection services, Action <DbContextOptionsBuilder> options) where TPageContext : DbContext, IDynamicPagesContext { services.AddScopedContextFactory <IDynamicPagesContext, TPageContext>(); services.AddDbContext <TPageContext>(options); services.RegisterAuditFor <IDynamicPagesContext>("Page module"); SystemEvents.Database.OnMigrate += (sender, args) => { GearApplication.GetHost <IWebHost>().MigrateDbContext <TPageContext>(); }; return(services); }
/// <summary> /// Add calendar module storage /// </summary> /// <typeparam name="TDbContext"></typeparam> /// <param name="configuration"></param> /// <param name="options"></param> /// <returns></returns> public static CalendarServiceCollection AddCalendarModuleStorage <TDbContext>( this CalendarServiceCollection configuration, Action <DbContextOptionsBuilder> options) where TDbContext : DbContext, ICalendarDbContext { Arg.NotNull(configuration.Services, nameof(AddCalendarModuleStorage)); configuration.Services.AddDbContext <TDbContext>(options, ServiceLifetime.Transient); configuration.Services.AddScopedContextFactory <ICalendarDbContext, TDbContext>(); configuration.Services.RegisterAuditFor <ICalendarDbContext>($"{nameof(Calendar)} module"); SystemEvents.Database.OnAllMigrate += (sender, args) => { GearApplication.GetHost <IWebHost>().MigrateDbContext <TDbContext>(); }; return(configuration); }