PostGet Trigger
- PostGet Trigger programs are executed after an instance is retrieved from the system.
- Used for logging, notifications, or other post-access actions.
- Cannot prevent access to the instance (runs after retrieval).
Coding Guidelines
- Implement the async interface for all new logic:
public interface IPostGetTriggerProgram
{
void Run(Guid instanceId);
}
public interface IPostGetTriggerProgramAsync
{
Task RunAsync(Guid instanceId);
}
- The trigger receives the
instanceIdof the accessed instance.
Example Program
Below is a sample structure for a PostGet trigger program. Unlike PreGet, PostGet triggers are typically used for actions such as logging or notifications after an instance is accessed. Business validation or access control logic should not be implemented here, as PostGet runs after the instance has already been retrieved.
public class PostGetTriggerProgram : IPostGetTriggerProgramAsync
{
public IInstanceService InstanceService { get; set; }
public IUserService UserService { get; set; }
// ... other services ...
public async Task RunAsync(Guid instanceId)
{
// Example: Log access or send notification
// This is a placeholder for post-access logic, such as:
// - Logging that the instance was accessed
// - Sending a notification to the user or admin
}
}
Best Practices
- Use async methods for all service/API calls.
- Keep logic robust and non-blocking.
Anti-patterns
- Do not attempt to block or reverse access to the instance.
- Avoid business validations that should occur before retrieval.
- Do not update or promote the same instance in this trigger. This may block updates to the instance from the API service due to instance lock operations.