public IServiceProvider ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddCors(options => { options.AddPolicy("AfaqPolicy", builder => { builder.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod(); }); }); services.AddMvc(); services.AddDbContext(); services.AddControllers(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Afaq API", Version = "v1" }); }); return(ContainerSetup.InitializeWeb(Assembly.GetExecutingAssembly(), services)); }
public IServiceProvider ConfigureProductionServices(IServiceCollection services) { // Add database services.AddDbContext(Configuration.GetConnectionString("AppConnection")); services.AddDbContext <AppDbContext>(c => c.UseSqlServer(Configuration.GetConnectionString("AppConnection"))); ConfigureServices(services); return(ContainerSetup.InitializeWeb(Assembly.GetExecutingAssembly(), services)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddDbContext(); //services.AddDbContext<AppDbContext>(opts => // opts.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); //services.AddSingleton<IDomainEventDispatcher, DomainEventDispatcher>(); services.AddControllersWithViews().AddNewtonsoftJson(); services.AddRazorPages(); services.AddSwaggerGen(c => c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" })); ContainerSetup.InitializeWeb(Assembly.GetExecutingAssembly(), services); }