// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddDbContext <nhrappdataContext>(options => { options.UseMySql(Configuration.GetConnectionString("DefaultConnection"), mySqlOptionsAction: MySqlOptions => { MySqlOptions.EnableRetryOnFailure( maxRetryCount: 10, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null); }); }); services.AddTransient <IRepository <Employee>, EmployeeRepository>(); // Register the Swagger generator services.AddSwaggerGen(c => { c.SwaggerDoc( "v1", new Info { Title = "My API", Version = "v1" }); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(c => { c.AddPolicy("AllowOrigin", options => options.AllowAnyOrigin()); }); services.AddAutoMapper(typeof(Startup)); services.AddMvc(); services.AddDbContext <heroku_4f2def07091704cContext>(options => options.UseMySql(Configuration.GetConnectionString("LocalConnection"), mySqlOptionsAction: MySqlOptions => { MySqlOptions.EnableRetryOnFailure( maxRetryCount: 4, maxRetryDelay: TimeSpan.FromSeconds(10), errorNumbersToAdd: null ); })); services.AddControllers(); services.Configure <AppSettings>(Configuration.GetSection("AppSettings")); //services.AddTokenAuthentication(Configuration); services.AddAuthentication() .AddGoogle(googleOptions => { // Đọc thông tin Authentication:Google từ appsettings.json IConfigurationSection googleAuthNSection = Configuration.GetSection("Authentication:Google"); // Thiết lập ClientID và ClientSecret để truy cập API google googleOptions.ClientId = googleAuthNSection["ClientId"]; googleOptions.ClientSecret = googleAuthNSection["ClientSecret"]; }); services.AddTransient <IRepository <Boards>, EntityRepository <Boards> >(); services.AddTransient <IBoardService, BoardService>(); services.AddTransient <IRepository <Users>, EntityRepository <Users> >(); services.AddTransient <IUserService, UserService>(); services.AddTransient <IRepository <Jobs>, EntityRepository <Jobs> >(); services.AddTransient <IJobService, JobService>(); }