// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var conn = Configuration.GetConnectionString("PixgramDbContextConnection"); services.AddDbContext <PixgramDbContext>(options => options.UseSqlServer(conn)); services.AddScoped(f => CartSession.GetCart(f)); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddMemoryCache(); services.AddSession(options => { options.Cookie.Name = ".ToolShed.Cart.Session"; options.IdleTimeout = TimeSpan.FromDays(2); }); services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }
public void ConfigureServices(IServiceCollection services) { var conn = _configuration.GetConnectionString("ToolShedProducts"); services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer(conn)); services.AddTransient <IProductRepository, ProductRepository>(); //services.AddTransient<IPasswordValidator<IdentityUser>, CorporatePasswordValidator>(); //services.AddTransient<IUserValidator<IdentityUser>, CorporateUserValidator>(); //services.AddAutoMapper(); services.AddIdentity <IdentityUser, IdentityRole>(). AddEntityFrameworkStores <ApplicationDbContext>(). AddDefaultTokenProviders(); services.AddTransient <IIdentitySeeder, IdentitySeeder>(); services.Configure <IdentityOptions>(options => { options.Password.RequireDigit = false; options.Password.RequireLowercase = false; options.Password.RequireNonAlphanumeric = false; options.Password.RequireUppercase = false; options.Password.RequiredLength = 3; }); services.Configure <RouteOptions>(options => options.LowercaseUrls = true); services.AddScoped(f => CartSession.GetCart(f)); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddTransient <IOrderRepository, OrderRepository>(); services.AddMemoryCache(); services.AddSession(options => { options.Cookie.Name = ".ToolShed.Cart.Session"; options.IdleTimeout = TimeSpan.FromDays(2); }); services.AddMvc(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().AddJsonOptions( options => options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore ); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); var conn = _configuration.GetConnectionString("Picks"); services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer(conn)); // Project services. services.AddTransient <IImageRepository, ImageRepository>(); services.AddTransient <IImageService, ImageService>(); services.AddTransient <ICategoryRepository, CategoryRepository>(); services.AddTransient <ICategoryService, CategoryService>(); services.AddTransient <CartSession>(); services.AddTransient <UploadImageHelper>(); services.AddTransient <AzureCognitiveServicesSettings>(); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddScoped(x => CartSession.GetCart(x)); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddMemoryCache(); services.AddSession(opt => { opt.Cookie.Name = "Picks.io"; }); services.AddDistributedRedisCache(opt => { opt.Configuration = _configuration.GetConnectionString("Redis"); //opt.InstanceName = "main_"; }); services.AddAutoMapper(); }