// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddAutoMapper(typeof(Startup)); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0); services.AddMvc(option => option.EnableEndpointRouting = false); services.AddDbContext <AppDbContext>(OptionsBuilderConfigurationExtensions => { OptionsBuilderConfigurationExtensions.UseInMemoryDatabase("supermarket-api-in-memory"); }); services.AddScoped <ICategoryRepository, CategoryRepository>(); services.AddScoped <IProductRepository, ProductRepository>(); services.AddScoped <ICategoryService, CategoryService>(); services.AddScoped <IProductService, ProductService>(); services.AddScoped <IUnitOfWork, UnitOfWork>(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <DataContext>(OptionsBuilderConfigurationExtensions => OptionsBuilderConfigurationExtensions.UseInMemoryDatabase("StorageDB")); services.AddControllers(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Backend", Version = "v1" }); }); services.AddCors(o => o.AddPolicy("MyPolicy", builder => { builder .SetIsOriginAllowed(_ => true) .AllowCredentials() .AllowAnyMethod() .AllowAnyHeader(); })); }