// This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //AutoFac,NinJect,CastleWindor,StructureMap,LightInject,DryIncject-->IOC Container
            //AOP
            services.AddControllers();
            //services.AddSingleton<IProductService, ProductManager>();
            //services.AddSingleton<IProductDal, EfProductDal>();
            //Singleton =eðer sen product service görürsen karþýlýðý product managerdir.
            //Ýçinde data tutmuyorsak singleton
            // Biri Service isterse ona arka planda productmanager ver
            var tokenOptions = Configuration.GetSection("TokenOptions").Get <TokenOptions>();

            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options =>
            {
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuer           = true,
                    ValidateAudience         = true,
                    ValidateLifetime         = true,
                    ValidIssuer              = tokenOptions.Issuer,
                    ValidAudience            = tokenOptions.Audience,
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = SecurityKeyhelper.CreateSecurityKey(tokenOptions.SecurityKey)
                };
            });
        }
        public AccessToken CreateToken(User user, List <OperationClaim> operationClaims)
        {
            _accessTokenExpiration = DateTime.Now.AddMinutes(_tokenOptions.AccessTokenExpiration);
            var securityKey        = SecurityKeyhelper.CreateSecurityKey(_tokenOptions.SecurityKey);
            var signingCredentials = SigningCredentialsHelper.CreateSigningCredentials(securityKey);
            var jwt = CreateJwtSecurityToken(_tokenOptions, user, signingCredentials, operationClaims);
            var jwtSecurityTokenHandler = new JwtSecurityTokenHandler();
            var token = jwtSecurityTokenHandler.WriteToken(jwt);

            return(new AccessToken
            {
                Token = token,
                Expiration = _accessTokenExpiration
            });
        }