Guidance on Creating a Reusable Service

I’m working on a project generated by ASP.NET Maker and would like to follow best practices to create a reusable service (e.g., TarefaWorkflowService) that encapsulates business logic such as task execution and workflow step finalization.

My goal is to move this logic out of controller-level private methods and into a dedicated class that can be injected into controllers via ASP.NET Core’s built-in dependency injection (DI).

I would like your guidance on the following points:

  1. What is the recommended way to add custom services like this to an ASP.NET Maker project so that they are preserved during project regeneration?
  2. Can the Service_Add(IServiceCollection services) server event be used to register custom services manually?
  3. Where should such service classes (.cs files) be stored within the ASP.NET Maker project to avoid being overwritten or deleted during regeneration? (e.g., a /Services folder)
  4. Is it recommended to use Resolve<T>() to access these services inside server events like Row_Inserted or Row_Updating?

Our main objective is to structure the business logic in a clean, reusable way while ensuring it remains compatible with ASP.NET Maker’s generation model.

Thank you in advance for your assistance.

You can add your service in the Service_Add server event and put your custom class in Custom File.