Class EntityGuard
- Namespace
- Integrations.Application.Entities
- Assembly
- Integrations.Application.dll
Loads an entity for an operation and enforces caller access, active status and feature flags.
public sealed class EntityGuard
- Inheritance
-
EntityGuard
- Inherited Members
Constructors
EntityGuard(IAppDbContext, ICallerContext)
Loads an entity for an operation and enforces caller access, active status and feature flags.
public EntityGuard(IAppDbContext db, ICallerContext caller)
Parameters
dbIAppDbContextcallerICallerContext
Methods
RequireAsync(string, CancellationToken)
Loads the entity, checking the caller may access it and that it is active.
public Task<LegalEntity> RequireAsync(string entityId, CancellationToken ct)
Parameters
entityIdstringctCancellationToken
Returns
RequireCompanyCode(LegalEntity)
The AvaTax company code, or a clear error when the entity has not been set up in AvaTax yet.
public static string RequireCompanyCode(LegalEntity entity)
Parameters
entityLegalEntity
Returns
RequireCompanyId(LegalEntity)
The entity's AvaTax company id; a conflict when it is not configured.
public static int RequireCompanyId(LegalEntity entity)
Parameters
entityLegalEntity
Returns
RequireFeature(LegalEntity, bool, string)
Throws FeatureDisabledException when the entity's feature flag is off.
public static void RequireFeature(LegalEntity entity, bool enabled, string feature)
Parameters
entityLegalEntityenabledboolfeaturestring