A service class in the Znode ecosystem is usually the last managed tier which breaks a requested user operation into several small-sized business logic instructions, data handling, and database transactions. It resides in the “Znode.Engine.Services” namespace.
The service classes are usually constructor-injected into API controllers or in some cases Cache helper classes.
Extending or Creating a Service
OOTB Znode has Znode.Api.Custom for extending the services in the SDK from the Full Source Code. Inside the \ZnodeMultifront\Projects\Libraries\Znode.Api.Custom project, the services and the IServices are extended. This same custom project can be utilized for creating a new service.
To extend a service, under Znode.Api.Custom > Service > IService, create a new interface with an appropriate name suffixed with the word “service”. (For Example, We will create ICustomOrderService.cs)
Next, under the Service > Service, create a new class with a similar name to the interface (just exclude the letter “I” in the beginning). This class should inherit the service you are trying to extend from the full source code, as well as implement the newly created service interface. (For example, we create a CustomOrderService which will inherit the OrderService that is present in the full source code).
Make sure that all the new service interfaces and service classes reside within the “Znode.Api.Custom.Service” namespace.
In the service interface, define all the members that are to be exposed to other components of Znode.
Implement all the exposed members in the child service class. The service class can also contain private members which are only to be used within the scope of this class itself.
Once the service interface and service class are ready to be used, make sure to register them both into the dependency registry which can be found in the “DependencyRegistration.cs” class under “Znode.Api.Custom” > Helper.
For reference, OOTB Znode already has a service extended called "CustomPortalService.cs" which can be used as a reference to extend other services in OOTB Znode.