示例#1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env
                              , IMultiTenantRepositoryBase <Tenant> tenantRepositoy
                              , ICacheManager <Tenant> cacheManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();
            app.UseMiddleware <MultiTenantMiddleware>();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
            foreach (var temp in tenantRepositoy.GetAll().ToList())
            {
                cacheManager.Add(temp.HostName, temp);
            }
        }
        // GET: Users
        public async Task <IActionResult> Index()
        {
            var multiTenancyDbContext = _repository.GetAll();

            return(View(await multiTenancyDbContext.ToListAsync()));
        }
 // GET: Tenants
 public async Task <IActionResult> Index()
 {
     return(View(await _repository.GetAll().ToListAsync()));
 }
示例#4
0
 // GET: Orders/Create
 public IActionResult Create()
 {
     ViewData["TenantId"] = new SelectList(_tenantRepository.GetAll(), "Id", "Id");
     ViewData["UserId"]   = new SelectList(_userRepository.GetAll(), "Id", "Id");
     return(View());
 }
        // GET: Goods
        public async Task <IActionResult> Index()
        {
            var multiTenancyDbContext = isLocal? _repository.GetAll().IgnoreQueryFilters(): _repository.GetAll();

            return(View(await multiTenancyDbContext.ToListAsync()));
        }