// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers().AddNewtonsoftJson(options => { var resolver = options.SerializerSettings.ContractResolver; if (resolver != null) { (resolver as DefaultContractResolver).NamingStrategy = null; } }); var connSection = Configuration.GetSection("ConnectionStrings"); services.Configure <ConnectionSettings>(connSection); var connSettings = connSection.Get <ConnectionSettings>(); var appSection = Configuration.GetSection("ApplicationSettings"); services.Configure <ApplicationSettings>(appSection); var appSettings = appSection.Get <ApplicationSettings>(); var key = Encoding.UTF8.GetBytes(appSettings.ClientSecret); services.AddDbContext <AuthenticationContext>(options => options.UseSqlServer(connSettings.IdentityConnection)); services.AddDbContext <JungleDbContext>(options => options.UseSqlServer(connSettings.JungleDbConnection)); // Add default identity services.AddIdentity <ApplicationUser, IdentityRole>(). AddEntityFrameworkStores <AuthenticationContext>(). AddDefaultTokenProviders(); // configure identity options to override default options services.Configure <IdentityOptions>(options => { options.Password.RequireDigit = false; options.Password.RequireNonAlphanumeric = false; options.Password.RequireLowercase = false; options.Password.RequireUppercase = false; options.Password.RequiredLength = 4; }); AuthorizationHelper.AddAuthentication(services, key); services.AddTransient <IEmployeeService, EmployeeService>(); services.AddTransient <ICustomerService, CustomerService>(); services.AddTransient <IChartService, ChartService>(); services.AddTransient <ICustomerOrderService, CustomerOrderService>(); services.AddTransient <IProductService, ProductService>(); services.AddScoped(typeof(IRepository <>), typeof(Repository <>)); services.AddCors(); }