Skip to content

Server Base Templates

damiancosmoschapman edited this page Oct 5, 2021 · 1 revision

Home / Developer / Server Tier / Base Templates

PxStat Application Server Side Base Template definitions, Properties, Methods and Abstract Methods.

Summary.

The available API classes generally call BSO classes in order to Create, Read,Update, Delete and other functions. Because most of the BSO classes share a great deal of functionality, it is useful to confine these common functions to base classes and allow the individual BSO classes to inherit them. The Base Template class is defined as a Generic in order for it to use a variety of DTO and Validator objects, and the inheriting classes use similar generics in order to inject the DTO and Validator objects.

Base Template.

All of the other Base Template classes inherit this class.

Properties:

  • Ado - An instance of the ADO class to enable database interaction.
  • Username - The username invoking the API.
  • Response - The ADO output.
  • Validator - The validator class (injected in the constructor).
  • Request - The Request delivered with the API call (injected in the constructor).
  • DTO - An object representing the parameters used in the API call.
  • cDTO - An object containing metadata for cache operations.
  • DTOValidationResult - A FluentValidation validation result.

Methods:

  • Constructor - initialize the properties, Create the Trace.
  • Dispose - Disposes any objects that need disposing.
  • IsModerator - Indicates if the user is a Moderator.
  • IsPowerUser - Indicates if the user is a Power User.
  • IsAdministrator - Indicates if the user is an Administrator.
  • IsApprover - Indicates if the user is an Approver (not implemented).
  • HasUserPrivilege - Indicates if the user is an Administrator OR the inheriting class HasPrivilege() function returns true.

Abstract Methods (to be inherited):

  • OnExecutionSuccess.
  • OnExecutionError.
  • HasPrivilege.

Default Methods.

  • GetDTO - Returns the DTO.
  • OnDTOValidationError.
  • OnPrivilegeError.
  • OnAuthenticationSuccessful.
  • OnAuthenticationFailed.
  • OnPrivilegeSuccess.
  • HasUserToBeAuthenticated.
  • IsUserAuthenticated.

Base Template Read.

Inherits the Base Template. Inherited by BSO_Read classes.

Methods:

  • Constructor - Checks authentication, cleans the parameters, gets the DTO, Sanitizes the DTO, runs validation, creates analytics (if required), reads cache (if required), catches errors and disposes.

Base Template Create.

Inherits the Base Template. Inherited by BSO_Create classes.

Methods:

  • Constructor - Checks authentication, cleans the parameters, gets the DTO, Sanitizes the DTO, runs validation, flushes cache if necessary, manages transaction, catches errors and disposes.

Base Template Update.

Inherits the Base Template. Inherited by BSO_Update classes.

Methods:

  • Constructor - Checks authentication, cleans the parameters, gets the DTO, Sanitizes the DTO, runs validation, flushes cache if necessary, manages transaction, catches errors and disposes.

Base Template Delete.

Inherits the Base Template. Inherited by BSO_Delete classes.

Methods:

  • Constructor - Checks authentication, cleans the parameters, gets the DTO, Sanitizes the DTO, runs validation, flushes cache if necessary, manages transaction, catches errors and disposes.