// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(options => { options.AddPolicy("localhost", builder => { builder .WithOrigins("http://localhost:4200") .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials(); }); }); services.AddDbContext <AppDbContext>(options => options.UseSqlServer(ConnectionBuilderHelper.GetDefaultConnectionString())); var rabbitMq = ConnectionBuilderHelper.BuildDefault().GetSection(nameof(RabbitMq)).Get <RabbitMq>(); services.AddSingleton <IRabbitMqService>(options => { var rabbitMqService = new RabbitMqService(rabbitMq); rabbitMqService.Start(); return(rabbitMqService); }); services.AddScoped <IFibCalcService, FibCalcService>(); services.AddScoped <IFibDbService, FibDbService>(); services.AddControllers(); }
public AppDbContext CreateDbContext(string[] args) { var optionsBuilder = new DbContextOptionsBuilder <AppDbContext>(); optionsBuilder.UseSqlServer(ConnectionBuilderHelper.GetDefaultConnectionString()); return(new AppDbContext(optionsBuilder.Options)); }