示例#1
0
        public static IServiceCollection AddIdentityServices(this IServiceCollection services, string configPath = null)
        {
            IConfiguration config = ConfigurationProvider.GetConfiguration(configPath);

            var connectionString = config.GetConnectionString(nameof(IdentityContext));

            if (connectionString == null)
            {
                throw new Exception($"No connectionString {nameof(IdentityContext)} from config");
            }

            services.AddDbContext <IdentityContext>(options => options.UseNpgsql(connectionString));
            services.AddScoped <IIdentityRepository, IdentityRepository>();

            return(services);
        }
示例#2
0
        public static IServiceCollection AddInfrastructureServices(this IServiceCollection services, string configPath = null)
        {
            services.AddTransient <IUnitOfWork, UnitOfWork>();
            services.AddTransient <IPublicationAsyncRepository, PublicationAsyncRepository>();

            IConfiguration config = ConfigurationProvider.GetConfiguration(configPath);

            var connectionString = config.GetConnectionString(nameof(ApplicationContext));

            if (connectionString == null)
            {
                throw new Exception($"No connectionString {nameof(ApplicationContext)} from config");
            }

            services.AddDbContext <ApplicationContext>(options => options.UseNpgsql(connectionString));
            return(services);
        }