public void ConfigureServices(IServiceCollection services)
        {
            services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info {
                    Title = "API"
                }); });

            services.CreateAutoMapper();

            services.AddMvc()
            .AddApplicationPart(typeof(ApiController).Assembly)
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            var dbHelper = new DbConnectionHelper(Configuration);

            services
            .AddEntityFrameworkNpgsql()
            .AddDbContext <CompositeKeyContext>(options =>
            {
                options.UseNpgsql(dbHelper.GetConnectionString(),
                                  b =>
                {
                    b.MigrationsAssembly(typeof(CompositeKeyContext).Assembly.GetName().Name);
                    b.ProvideClientCertificatesCallback(dbHelper.ProvideClientCertificatesCallback);
                    b.RemoteCertificateValidationCallback(
                        dbHelper.RemoteCertificateValidationCallback);
                });
                options.UseOpenIddict();
            })
            .BuildServiceProvider();
        }
Exemple #2
0
        public void GetConnectionStringTest()
        {
            DbSource           dbSource   = new DbSource();
            DbConnectionHelper helper     = new DbConnectionHelper(dbSource);
            string             connection = helper.GetConnectionString("Odbc Data Provider");

            Assert.IsNotNull(connection);
        }
        protected CompositeKeyContext GetContext(IConfiguration configuration)
        {
            var dbHelper       = new DbConnectionHelper(Configuration);
            var ContextBuilder = new DbContextOptionsBuilder <CompositeKeyContext>();

            ContextBuilder.UseNpgsql(dbHelper.GetConnectionString(),
                                     b =>
            {
                b.MigrationsAssembly(typeof(CompositeKeyContext).Assembly.GetName().Name);
                b.ProvideClientCertificatesCallback(dbHelper.ProvideClientCertificatesCallback);
                b.RemoteCertificateValidationCallback(
                    dbHelper.RemoteCertificateValidationCallback);
            });
            return(new CompositeKeyContext(ContextBuilder.Options));
        }
Exemple #4
0
 private bool IsConnectionSuccessfull(ServerOption serverOption) => serverOption != null && (_dbConnectionService?.IsConnectionAvailable(DbConnectionHelper.GetConnectionString(serverOption.ServerName, serverOption.Username, serverOption.Password)) ?? false);
 public HanelContext()
 {
     _connectionString = DbConnectionHelper.GetConnectionString("HANELConnection");
 }
Exemple #6
0
 private SqlConnection SqlConnection(string _connectionString = "")
 {
     _connectionString = DbConnectionHelper.GetConnectionString("HANELConnection");
     return(new SqlConnection(_connectionString));
 }
 public KaryaContext()
 {
     _connectionString = DbConnectionHelper.GetConnectionString("KARYAConnection");
 }