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:
- 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?
- Can the
Service_Add(IServiceCollection services)
server event be used to register custom services manually? - 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) - Is it recommended to use
Resolve<T>()
to access these services inside server events likeRow_Inserted
orRow_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.