Пример #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();
            var connection = @"Server=DESKTOP-VDTQMNM;Database=RestaurantReviewerDb2;Trusted_Connection=True;ConnectRetryCount=0";

            services.AddDbContext <Models.Context>
                (options => options.UseSqlServer(connection));
            services.AddTransient <IRestaurantRepository, RestaurantRepository>();
            services.AddTransient <ICategoryRepository, CategoryRepository>();
            services.AddTransient <IReviewRepository, ReviewRepository>();
            services.AddTransient <IUserRepository, UserRepository>();
            services.AddTransient <IHttpContextAccessor, HttpContextAccessor>();
            services.AddScoped(sp => FavoriteCart.GetCart(sp));
            services.AddMvc();
            services.AddMemoryCache();
            services.AddSession();
        }
 public FavoriteCartController(IRestaurantRepository restaurantRepository, FavoriteCart favoriteCart)
 {
     _restaurantRepository = restaurantRepository;
     _favoriteCart         = favoriteCart;
 }
 public FavoriteCartSummary(FavoriteCart favoriteCart)
 {
     _favoriteCart = favoriteCart;
 }