コード例 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            pgsqlConnectionString = _configuration["Data:pgsqlConnectionString"];
            services.AddDbContext <AppDbContext>(options =>
                                                 options.UseNpgsql(pgsqlConnectionString));
            // services.AddTransient<ICategoryRepository, InMemoryCategoryRepository>();
            // services.AddTransient<ITourRepository, InMemoryTourRepository>();
            // Commenting the above lines as we now use the DB repositories as below:
            services.AddIdentity <IdentityUser, IdentityRole>()
            .AddEntityFrameworkStores <AppDbContext>()
            .AddDefaultTokenProviders();

            // services.Configure<IdentityOptions>(options => {
            //     options.Password.RequireDigit = false;
            //     options.Password.RequiredLength = 6;
            //     options.Password.RequireLowercase = false;
            //     options.Password.RequireNonAlphanumeric = false;
            //     options.Password.RequireUppercase = false;
            // });

            services.AddTransient <ICategoryRepository, CategoryRepository>();
            services.AddTransient <ITourRepository, TourRepository>();
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddScoped <TourCart>(sp => TourCart.Get(sp));
            services.AddTransient <IOrderRepository, OrderRepository>();
            services.AddMvc();
            services.AddMemoryCache();
            services.AddSession();
        }
コード例 #2
0
 public TourCartController(ITourRepository tourRepository, TourCart tourCart)
 {
     _tourRepository = tourRepository;
     _tourCart       = tourCart;
 }
コード例 #3
0
 public OrdersController(IOrderRepository orderRepository, TourCart tourCart)
 {
     _orderRepository = orderRepository;
     _tourCart        = tourCart;
 }
コード例 #4
0
 public TourCartSummary(TourCart tourCart)
 {
     _tourCart = tourCart;
 }