Coding Guidelines (ABP)
Things to keep in mind.
Since we are using EntityFramework, we often don't want to load complete entities for performance reasons, we should only manipulate Entities when we want to update the records, otherwise, it is recommended to always use projection.
Genisys Standard:
AppServices
AppServices are used to expose methods as WebAPI. They are "automagically" wrapped inside a ASP.NET Core Controller, which allows us to call them from a webpage or any other client.
AppServices can be created either for a specific UI Needs (for a specific webpage let's say), and they can also be built to integrate from application to application (what is usually called backend to backend), B2B.
AppServices should be defined in the "Application" project of your solution.
UI AppServices and B2B AppServices should not be merged together as they share different responsabilities. If you need to share code between these two, create "DomainServices", put that code in them and reuse your "DomainServices" in the corresponding AppServcies
AppServices for UI
We should create a single AppService per page, there might be multiple methods in it, you should have one method for each specific need in your page. Example, for a master file page, you might have multiple methods such as "Query", "Create", "Update", "Delete", etc... It will be easier to manage authorization as we usually manage these permissions per module/pages. Authorization should be based on specific permissions, a user usually needs to be authorized to access your UI.
AppServices for B2B
In some cases, we might need to expose some apis to applications, not necessary to a specific UI. In that case, we'll create a separated AppServices for each concept that we might want to expose. Authorization should be made through "client_credentials", a scope must be specified and the authorization filter will validate that the scope is allowed before calling your service.
AppServices DTOs
DTOS that are being exposed in the AppServices (as input params or output params) should be define the corresponding "Application.Contracts" project. Exceptions are DTOs that are needed inside DomainServices; in that case, DTOS must be defined in the "Domain.Shared" project.
DomainServices
DomainServices can be created when some logic needs to be shared between different AppServices. Do not create DomainServices right away, create them as you need them. DomainServices should not manage authorization, that is the responsibility of the AppServices even though ABP supports it. Domain Services can manipulate/expose both DTO and Entities, do it as it suits your need. This goes against ABP recommendation, but it makes sense for performance reason. Your DomainService should have a single responsibility (single public method) as much as possible. Name them meaningfully based on their responsibility, avoid ending with "DomainService" or "Manager" (this goes against ABP recommandation).
DomainServices should be defined in the "Domain" project of your solution.
DomainServices DTOs
DTOS that are being exposed in the DomainServices (as input params or output params) should be define the corresponding "Domain.Shared" project.
EventHandlers
To be defined
ETO (Event transfer objects)
To be defined.
When to use pipelines/filters
TO DEFINE clearly, but basic guideline is when your method ends up being more 15-20 lines (unless it's a query). It's all about complexity and the number of dependencies required for your actions, we try to inject as less dependencies as possible in the constructor of your Domain/AppServices.