Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            new AutoMapperConfiguration().ConfigureServices(services);

            //services.RegisterLogin(Configuration);
            services.AddSwaggerGen();
            services.AddMvc();

            // Services
            services.AddScoped <IMatchService, MatchService>();
            services.AddScoped <IPlayerMatchStatisticService, PlayerMatchStatisticService>();
            services.AddScoped <IPlayerService, PlayerService>();
            services.AddScoped <IPlayerMatchService, PlayerMatchService>();

            // Repos
            services.AddScoped <IMatchRepository, MatchRepository>();
            services.AddScoped <IPlayerMatchStatisticsRepository, PlayerMatchStatisticRepository>();
            services.AddScoped <IPlayerRepository, PlayerRepository>();
            services.AddScoped <IPlayerMatchRepository, PlayerMatchRepository>();

            // Auth
            services.AddAuthentication("Bearer")
            .AddIdentityServerAuthentication("Bearer", options =>
            {
                options.ApiName   = "RocketAPI";
                options.Authority = Configuration["OAuth:Domain"];
            });

            services.AddSingleton <IAuthorizationHandler, HasScopeHandler>();
            services.AddControllers();
            services.RegisterSecurityScopes(Configuration);

            DataServiceConfiguration.RegisterServices(services, Configuration);
        }