Base solution for your next web application

Activities of "bubba"

I'm having trouble understanding where to put code that is common for several appservices. Since I know it is bad to let one appservice use another appservice where can I put the code? And before you answer you need to know that this code is only making operations on an object that exists in Session and that is not defined anywhere in Core.

Right now I have put the code in a static helper class but it's not pretty. I'm sending in the domainservices I use as parameters to the static function and there are sometimes many of them.

So to repeat my question; I'm doing operations (using many domainservices) on a DTO that lives in Session; How do I best do this from several appservices without having to repeat my code?

I'm trying to use different layouts per tenant. The layouts are stored in database, but since layouts are set in _Viewstart.cshtml I am having trouble. How can I access an appservice from _Viewstart.cshtml?

If I don't set the layout in _viewstart I would have to set it on every "return View(...)" and that is not a good option as I have hundreds of those.

I can access a static method in a controller from _Viewstart like this:

string theme = Gentide.Web.Controllers.TenantsController.GetTenantTheme(HttpContext.Current.Request.Url.Host);

    Layout = "~/Views/Shared/_Layout" + theme + ".cshtml";

But since it is static I cannot access any appservice instances that that controller have injected :( ... which also means I have to access the database directly (not using repositories), for example:

db.Tenants.FirstAsync(x => x.TenancyName == host)

and which also means that I cannot use the CacheManager. As you can see it's not really a good solution.

Here is what I would like to do:

string theme = _tenantAppservice.GetCurrentTenantTheme();

or perhaps directly if that would be easier for some reason:

Tenant tenant = await CacheManager
                   .GetCache(MyConsts.MyCache)
                   .Get(HttpContext.Current.Request.Url.Host + MyConsts.TENANT_CACHE_KEY, async () => await _tenantManager.GetTenant(HttpContext.Current.Request.Url.Host));
string theme = tenant.Theme;

Any advice is appreciated!

I'm just getting started using Boilerplate (MPA) and my aim is to build a multi tenant system where each tenant can create their own pages. I noticed however that the menu is created at startup (in other words, it's "hard coded" and not dynamic :| ) and I cannot figure out how to change it to reflect the different tenants pages.

The only solution I can think of is hiding the built in menu completely and render my own menu, but I would like to know if it is possible to utilize the built in one? :?:

Any help, hints or advice will be helpful.

Showing 1 to 3 of 3 entries