The typical architecture I am using consists of Manager objects in the Business Layer. I am using DI/IOC within .NET Core/ .NET Standard. The managers are injected into the service layer and consequently the services are injected into our API controllers. So I am presently working in a Manager class. I now need a method that resides in another manager class. Usually I return back through the service layer to the controller, then call the next service and then the manager through that.
I am wondering whether it is OK to just inject a Manager I require directly into the Manager I am working in. Therefore cutting out the trip back to the controller and then back up through the other service to the other manager. Basically I have 2 * Managers.
public class TypeCodeManager : ITypeCodeManager { public TypeCodeManager() { } public async Task<int> GetTypeCodeAsync(string typeCode, string code) } public class UserManager : IUserManager { private readonly ITypeCodeManager _typeCodeManager; public UserManager(ITypeCodeManager typeCodeManager) { _typeCodeManager = typeCodeManager } } Is this generally a good idea?
I am wondering whether it is OK to...Depends on what you mean byOK.