// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <PoliceStationManagementIdentityDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("IdentityConnection"))); services.AddIdentity <ApplicationUser, IdentityRole>() .AddEntityFrameworkStores <PoliceStationManagementIdentityDbContext>() .AddDefaultTokenProviders(); // Add application services. services.AddTransient <IEmailSender, EmailSender>(); services.AddLocalization(options => options.ResourcesPath = "Localization"); services.AddMvc().AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix, options => options.ResourcesPath = "Localization").AddDataAnnotationsLocalization(); services.AddSession(options => { options.IdleTimeout = TimeSpan.FromMinutes(30); }); ServiceContainerConfigurator.ConfigureServices( Configuration.GetConnectionString("DefaultConnection"), services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <GuestbookIdentityDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("IdentityConnection"))); services.AddIdentity <ApplicationUser, IdentityRole>() .AddEntityFrameworkStores <GuestbookIdentityDbContext>() .AddDefaultTokenProviders(); // Add application services. services.AddTransient <IEmailSender, EmailSender>(); services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); ServiceContainerConfigurator.ConfigureServices( Configuration.GetConnectionString("DefaultConnection"), services); // Register the Swagger generator, defining 1 or more Swagger documents services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Guestbooks API", Version = "v1" }); }); }
public void ConfigureServices(IServiceCollection services) { IConfigurationRoot configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); ServiceContainerConfigurator.ConfigureServices( configuration.GetConnectionString("DefaultConnection"), services); }