Base solution for your next web application

Activities of "bubba"

Surely the user sessions must be kept somewhere serverside as well...

Answer

If you display a message together with the username, then the MessageDTO should contain the username as well.

In my eyes nr 1 and 2 are the same. In the application layer you have "public MessageDTO GetMessage()". The MessageDTO contains the username. The method is not specific for any particular view - you could consume this method from many different presentation layers that wants to show a message. Just skip the "ForView"-part when naming the method 8-)

Thank you for your reply.

This forum post told me that it was bad: #1028@04dacffb-ff73-44de-bd9a-d17e1b6edf03

I actually ignored that advice at first and let my appservices use each other as needed, but when I had a controller use 2 appservices which in turn used eachother I got a circular reference error.

Spreading the common code into baseclass, managers and helpers works, but it also works with using just helpers like I already do.

The thing is I would like to know the best practise way. So all of you gurus out there feel free to join in ;)

Anyone?

An example of such code could be:

// ci is the DTO and this code is used by several appservices. Where to put it so I can follow "DRY" and without letting one appservice reference another appservice? 

ci.Price = await _exchangeRatesManager.GetPriceInCurrentCurrency(ci.Price, geo.Currency); 
// _exchangeRatesManager is a domain service
ci.Tax = await _taxManager.GetTax(geo.Region, ci.Price, ci.TaxClass);
// _taxManager is a domain service
ci.xx = await ... 
...

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 solved it finally. For anyone else looking for an answer, here is the solution: Somehow I had missed this in the documentation:

If you are in a static context or can not inject IIocManager, as a last chance, you can use singleton object IocManager.Instance everywhere.

So now I can do this:

ITenantAppservice tenantAppservice = IocManager.Instance.Resolve<TenantAppservice>();
string theme = tenantAppservice.GetCurrentTenantTheme();

Sweet!

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 9 of 9 entries