public RenewController( DdnsDbContext context , IEtcdRepostitory etcdRepo , ILogger <RenewController> logger ) { _context = context; _etcdRepo = etcdRepo; _logger = logger; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CoreDdnsOptions>(Configuration); services.AddMemoryCache(); services.AddMvc(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "DdnsRegister", Version = "v1" }); }); #if false // メモリデータベース { services.AddDbContext <DdnsDbContext>(optionsBuilder => { var options = optionsBuilder .UseInMemoryDatabase(databaseName: "Startup") .Options; using (var context = new DdnsDbContext((DbContextOptions <DdnsDbContext>)options)) { context.ddnshost.Add(new ddnshost { name = "test01", hash = "hash01", isvalid = true, }); context.SaveChanges(); } }); } #endif services.AddDbContext <DdnsDbContext>(options => options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection"))); // ログイン用のデータベースに利用する場合 //services.AddIdentity<ApplicationUser, IdentityRole>() // .AddEntityFrameworkStores<DdnsDbContext>() // .AddDefaultTokenProviders(); services.AddTransient <IEtcdRepostitory, EtcdRepository>(); }