// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <ApplicationDbContext>( options => options .UseLazyLoadingProxies() .EnableSensitiveDataLogging() .UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddDefaultIdentity <ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true) .AddEntityFrameworkStores <ApplicationDbContext>(); services.AddControllersWithViews(); services.AddTransient <IEmailSender, EmailSender>(); services.Configure <MailSettings>(Configuration.GetSection("MailSettings")); IdentityConfiguration.ConfigureIdentity(services); services.AddRazorPages(); CustomDIMappings.AddApplicationDIMappings(services); services.AddControllers(config => { var policy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); config.Filters.Add(new AuthorizeFilter(policy)); }); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddDbContext <Context>(options => options.UseSqlServer(Configuration.GetConnectionString("Connection"))); IdentityConfiguration.AddIdentity(services); services.AddCors(); services.AddMvc(); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddSingleton <UrlResolver>(); IdentityConfiguration.ConfigureIdentity(services); services.AddSingleton(_ => Configuration as IConfigurationRoot); services.AddScoped <PasswordHasher <User> >(); services.AddScoped <IUserRepository, UserRepository>(); services.AddScoped <IEventRepository, EventRepository>(); services.AddScoped <IEventService, EventService>(); services.AddScoped <IStatusService, StatusService>(); services.AddScoped <IStatusRepository, StatusRepository>(); services.AddScoped <ICommentRepository, CommentRepository>(); services.AddScoped <ICommentService, CommentService>(); services.AddScoped <IUserService, UserService>(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "CoolMeet API", Version = "v1" }); }); services.AddAutoMapper(); JwtConfiguration.AddJwtAuthorization(Configuration, services); }
public void ConfigureServices(IServiceCollection services) { services.AddCors(); ApplicationInsightsTelemetryConfiguration.ConfigureApplicationInsightsTelemetry(services, Configuration); FiltersConfiguration.ConfigureFilter(services); DatabaseConfiguration.ConfigureDatabae(services, Configuration); IdentityConfiguration.ConfigureIdentity(services); JwtConfiguration.ConfigureJwtAuthService(services, Configuration); DependencyInjectorConfiguration.ConfigureDependencyInjector(services, Configuration); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddDbContext <ExampleContext>( options => { options.UseSqlServer(Configuration.GetConnectionString("LocalDb")); }); IdentityConfiguration.AddIdentity(services); services.AddCors(); services.AddMvc(); IdentityConfiguration.ConfigureIdentity(services); services.AddSingleton(sp => AutoMapperConfig.Initialize()); services.AddSingleton(_ => Configuration as IConfigurationRoot); services.AddScoped <PasswordHasher <User> >(); services.AddScoped <IAuthService, AuthService>(); JwtConfiguration.AddJwtAuthorization(Configuration, services); }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMemoryCache(); services.AddDbContext <PgsKanbanContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); IdentityConfiguration.AddIdentity(services); SwaggerConfiguration.ConfigureSwagger(services); SignalRConfiguration.AddSignalR(services); MvcConfiguration.AddMvc(services); IdentityConfiguration.ConfigureIdentity(services); CorsConfiguration.AddCors(services); OptionsRegistration.Configure(Configuration, services); services.AddSingleton <IMapper>(sp => AutoMapperConfig.Initialize()); JwtConfiguration.AddJwtAuthorization(Configuration, services); return(DependencyRegistration.Register(Configuration, services)); }