Base solution for your next web application

Activities of "primalpat"

I am looking for the "best practices" way. For example: If I have an AppService for tenants where a single function exists to create tenants, but in order to create a tenant I need to also create a different entity and save it to the database for an ID, how would I accomplish this without repeating code all over the place?

public class TenantAppService : ApplicationService, ITenantAppService
    {
        private readonly IRepository<Tenant, long> _tenantRepository;

        public TenantAppService(IRepository<Tenant, long> tenantRepository)
        {
            _tenantRepository = tenantRepository;
        }

        public void CreateTenant(CreateTenantInput input)
        {
            Logger.Info("Creating a tenant for input: " + input);

            //Create a new Address entity with given input's properties
        }
    }

Thank you for the quick reply Halil!

Your explanation about the application logic is very helpful and has made me realize I've been structuring my app incorrectly.. so I will have a bit of work to do to fix it.

Are there any examples or demos that demonstrate the interaction between a domain manager or service and an application service? I am trying to wrap my mind around it and cannot seem to find any mention of it in the documentation (probably because it is simple, and I am too new at this).

Thanks again.

Hello Halil,

I am still having some difficulty understanding how to access the Domain Service (Tenant Manager) from the App Service (Tenant App Service).

In your example, you use:

await TenantManager.GetByIdAsync(input.Id)

but I am unsure how you get a reference to TenantManager. I am guessing you use dependency injection, but I'm not exactly sure how. I have tried constructor injection, but am getting a not so descriptive error.

Showing 1 to 3 of 3 entries