// 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("ApiCorsPolicy", builder => { builder.WithOrigins("http://localhost", "http://localhost:4200").AllowAnyMethod().AllowAnyHeader(); })); services.AddControllers().AddNewtonsoftJson(opt => opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore); AppSettings.ConnectionString = Configuration.GetConnectionString("VSConnection"); DatabaseMigrator.StartMigration(); services.AddDbContext <VSDBContext>(item => item.UseSqlServer(Configuration.GetConnectionString("VSConnection"))); services.AddScoped <IVehicleService, VehicleService>(); services.AddScoped <ICustomerService, CustomerService>(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers().AddNewtonsoftJson(opt => opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); AppSettings.ConnectionString = Configuration.GetConnectionString("VSConnection"); DatabaseMigrator.StartMigration(); services.AddDbContext <VSDBContext>(options => options.UseSqlServer(AppSettings.ConnectionString)); services.AddScoped <IVehicleService, VehicleService>(); services.AddScoped <ICustomerService, CustomerService>(); }