Table of Contents

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

db IAppDbContext
caller ICallerContext

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

entityId string
ct CancellationToken

Returns

Task<LegalEntity>

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

entity LegalEntity

Returns

string

RequireCompanyId(LegalEntity)

The entity's AvaTax company id; a conflict when it is not configured.

public static int RequireCompanyId(LegalEntity entity)

Parameters

entity LegalEntity

Returns

int

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

entity LegalEntity
enabled bool
feature string