// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <AppDBContext>(options => options.UseSqlServer(Configuration["ConnectionStrings:DefaultConnection"])); services.AddControllers(); AutoMapperConfiguration.Init(); services.AddScoped <IUnitOfWork, UnitOfWork>(); services.AddScoped <IProductRepository, ProductService>(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(options => { options.AddPolicy(name: MyAllowSpecificOrigins, builder => { builder.WithOrigins("http://localhost:4200") .AllowAnyHeader() .AllowAnyMethod(); }); }); services.AddDbContext <AppDBContext>(options => options.UseSqlServer(Configuration["ConnectionStrings:DefaultConnection"])); services.AddControllers(); AutoMapperConfiguration.Init(); services.AddScoped <IUnitOfWork, UnitOfWork>(); services.AddScoped <IProductRepository, ProductService>(); services.AddScoped <ICategoryRepository, CategoryService>(); }