// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddScoped <ILookupProducts, EfSqlProducts>(); services.AddScoped <ICommandProducts, EfSqlProducts>(); services.AddDbContext <ShoppingDataContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("shopping")); }); var mapperConfiguration = new MapperConfiguration(opt => { opt.AddProfile(new ProductsProfile()); }); var mapper = mapperConfiguration.CreateMapper(); services.AddSingleton <IMapper>(mapper); services.AddSingleton <MapperConfiguration>(mapperConfiguration); // this is to get the markup percentage and apply it to the cost of the product. Kinda wonky but var configForPringing = new ConfigurationForPricing(); Configuration.GetSection(configForPringing.SectionName).Bind(configForPringing); services.Configure <ConfigurationForPricing>(Configuration.GetSection(configForPringing.SectionName)); }
// 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.AddDefaultPolicy(builder => { builder.WithOrigins("http://localhost:4200"); builder.AllowAnyHeader(); builder.AllowAnyMethod(); builder.AllowCredentials(); // if your passing a JWT or something }); }); services.AddControllers() .AddJsonOptions(options => { options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); options.JsonSerializerOptions.IgnoreNullValues = true; }); services.AddScoped <ILookupProducts, EfSqlProducts>(); services.AddScoped <IProductCommands, EfSqlProducts>(); services.AddDbContext <ShoppingDataContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("shopping")); }); var mapperConfiguration = new MapperConfiguration(opt => { opt.AddProfile(new ProductsProfile()); }); var mapper = mapperConfiguration.CreateMapper(); services.AddSingleton <IMapper>(mapper); services.AddSingleton <MapperConfiguration>(mapperConfiguration); //// this makes it so we just have those settings availble... demo coming. var configForPricing = new ConfigurationForPricing(); //Configuration.GetSection(configForPricing.SectionName).Bind(configForPricing); // this makes it so we can get this through IOptions<T>... services.Configure <ConfigurationForPricing>( Configuration.GetSection(configForPricing.SectionName)); services.AddSingleton <CurbsideChannel>(); services.AddHostedService <CurbsideOrderProcessor>(); services.AddSignalR().AddJsonProtocol(options => { options.PayloadSerializerOptions.Converters.Add(new JsonStringEnumConverter()); }); }