Class OrganisationManager<TOrganisation>
Provides the APIs for managing organisations in a persistence store.
Inherited Members
Namespace: IRM.AspNetCore.Identity
Assembly: IRM.AspNetCore.Identity.dll
Syntax
public class OrganisationManager<TOrganisation> : IOrganisationManager, IDisposable where TOrganisation : class, IOrganisation
Type Parameters
TOrganisation
The type encapsulating an organisation. |
Constructors
OrganisationManager(IOrganisationStore<TOrganisation>, IEnumerable<IOrganisationValidator<TOrganisation>>, IHttpContextAccessor, IOptions<ExtendedIdentityOptions>, ILogger<OrganisationManager<TOrganisation>>)
Constructs a new instance of OrganisationManager<TOrganisation>.
Declaration
public OrganisationManager(IOrganisationStore<TOrganisation> store, IEnumerable<IOrganisationValidator<TOrganisation>> organisationValidators, IHttpContextAccessor contextAccessor, IOptions<ExtendedIdentityOptions> optionsAccessor, ILogger<OrganisationManager<TOrganisation>> logger)
Parameters
IOrganisationStore<TOrganisation>
store
The persistence store the manager will operate over. |
IEnumerable<IOrganisationValidator<TOrganisation>>
organisationValidators
A collection of validators for organisations. |
Microsoft.AspNetCore.Http.IHttpContextAccessor
contextAccessor
The accessor used to access the Microsoft.AspNetCore.Http.HttpContext. |
Microsoft.Extensions.Options.IOptions<ExtendedIdentityOptions>
optionsAccessor
The accessor used to access the ExtendedIdentityOptions. |
Microsoft.Extensions.Logging.ILogger<OrganisationManager<TOrganisation>>
logger
The logger used to log messages, warnings and errors. |
Properties
Logger
Gets the Microsoft.Extensions.Logging.ILogger used to log messages from the manager.
Declaration
public virtual ILogger Logger { get; set; }
Property Value
Microsoft.Extensions.Logging.ILogger
|
OrganisationValidators
Gets a list of validators for organisation to call before persistence.
Declaration
public IEnumerable<IOrganisationValidator<TOrganisation>> OrganisationValidators { get; }
Property Value
IEnumerable<IOrganisationValidator<TOrganisation>>
|
Store
Gets the persistence store the manager operates over.
Declaration
protected IOrganisationStore<TOrganisation> Store { get; }
Property Value
IOrganisationStore<TOrganisation>
The persistence store the manager operates over. |
Methods
CreateAsync(TOrganisation)
Creates the specified organisation in the persistence store.
Declaration
public virtual async Task<IdentityResult> CreateAsync(TOrganisation organisation)
Parameters
TOrganisation
organisation
The organisation to create. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult of the creation operation. |
DeleteAsync(TOrganisation)
Deletes the specified organisation
.
Declaration
public virtual Task<IdentityResult> DeleteAsync(TOrganisation organisation)
Parameters
TOrganisation
organisation
The organisation to delete. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult of the deletion operation. |
Dispose()
Releases all resources used by the organisation manager.
Declaration
public void Dispose()
Implements
Dispose(Boolean)
Releases the unmanaged resources used by the organisation manager and optionally releases the managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Boolean
disposing
true to release both managed and unmanaged resources; false to release only unmanaged resources. |
FindByIdAsync(Guid)
Finds and returns an organisation, if any, that has the specified organisationId
.
Declaration
public async Task<TOrganisation> FindByIdAsync(Guid organisationId)
Parameters
System.Guid
organisationId
The organisation ID to search for. |
Returns
System.Threading.Tasks.Task<TOrganisation>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the organisation matching the specified |
FindByIdsAsync(Guid[])
Finds and returns a list of organisations, if any, who has any of the specified organisationIds
.
Declaration
public Task<List<TOrganisation>> FindByIdsAsync(params Guid[] organisationIds)
Parameters
System.Guid[]
organisationIds
The organisation ID to search for. |
Returns
System.Threading.Tasks.Task<List<TOrganisation>>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the tenants matching the specified |
FindByNameAsync(String, Nullable<Guid>)
Finds and returns an organisation, if any, that has the specified organisation name.
Declaration
public virtual Task<TOrganisation> FindByNameAsync(string organisationName, Guid? groupMotherId = null)
Parameters
String
organisationName
The organisation name to search for. |
System.Nullable<System.Guid>
groupMotherId
Specifies optional organisation to search within |
Returns
System.Threading.Tasks.Task<TOrganisation>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the organisation matching the specified |
FindByTrustedDomain(String)
Finds and returns an organisation, if any, associated with the specified domain name.
Declaration
public virtual Task<OrganisationKeys> FindByTrustedDomain(string domainName)
Parameters
String
domainName
The organisation trusted domain name to search for. |
Returns
System.Threading.Tasks.Task<OrganisationKeys>
The task object containing the results of the asynchronous lookup operation, the organisation if any associated with the specified domain name. |
FindTenantsByIdsAsync(Guid[])
Finds and returns a list of organisations, if any, who has any of the specified tenantIds
.
Declaration
public async Task<List<IOrganisation>> FindTenantsByIdsAsync(Guid[] tenantIds)
Parameters
System.Guid[]
tenantIds
The tenant ID to search for. |
Returns
System.Threading.Tasks.Task<List<IOrganisation>>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the tenants matching the specified |
Implements
GetAllAsync(OrganisationSearchQuery)
Gets all organisations matching the query
.
Declaration
public Task<QueryResult<TOrganisation>> GetAllAsync(OrganisationSearchQuery query)
Parameters
OrganisationSearchQuery
query
The query describing filtering and sorting for the organisations. |
Returns
System.Threading.Tasks.Task<QueryResult<TOrganisation>>
A System.Threading.Tasks.Task that represents the QueryResult<T> of the asynchronous query. |
GetTenantNameAsync(Guid)
Finds and returns the name of the tenant with the specified tenantId
.
Declaration
public async Task<string> GetTenantNameAsync(Guid tenantId)
Parameters
System.Guid
tenantId
The unique identity of the tenant. |
Returns
System.Threading.Tasks.Task<String>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the name of the tenant. |
Implements
NormalizeDomainName(String)
Normalizes a domain name for consistent and performant comparisons.
Declaration
public virtual string NormalizeDomainName(string domainName)
Parameters
String
domainName
The domain name to normalize. |
Returns
String
A normalized value representing the specified domain name. |
RaiseEvent(TOrganisation, OrganisationEvent[])
Adds an OrganisationEvent to the organisation with common properties set.
Declaration
protected virtual void RaiseEvent(TOrganisation organisation, params OrganisationEvent[] events)
Parameters
TOrganisation
organisation
The organisation to add the event to. |
OrganisationEvent[]
events
Collection of one or more OrganisationEvent to add. |
ThrowIfDisposed()
Throws an System.ObjectDisposedException if the organisation manager is disposed.
Declaration
protected void ThrowIfDisposed()
UpdateAsync(TOrganisation)
Updates the specified organisation
.
Declaration
public virtual async Task<IdentityResult> UpdateAsync(TOrganisation organisation)
Parameters
TOrganisation
organisation
The organisation to update. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult for the update. |
UpdateNormalizedDomainNameAsync(ITrustedDomain)
Updates the normalized domain name for the specified trusted domain.
Declaration
public virtual Task UpdateNormalizedDomainNameAsync(ITrustedDomain trustedDomain)
Parameters
ITrustedDomain
trustedDomain
The trused domain which domain name should be normalized and updated. |
Returns
System.Threading.Tasks.Task
The System.Threading.Tasks.Task that represents the asynchronous operation. |
ValidateOrganisationAsync(TOrganisation)
Should return Microsoft.AspNetCore.Identity.IdentityResult.Success if validation is successful. This is called before saving the organization via CreateAsync(TOrganisation) or UpdateAsync(TOrganisation).
Declaration
protected virtual async Task<IdentityResult> ValidateOrganisationAsync(TOrganisation organisation)
Parameters
TOrganisation
organisation
The organisation. |
Returns
System.Threading.Tasks.Task<IdentityResult>
A IdentityResult representing whether validation was successful. |
Explicit Interface Implementations
IOrganisationManager.FindByIdAsync(Guid)
Declaration
async Task<IOrganisation> IOrganisationManager.FindByIdAsync(Guid organisationId)
Parameters
System.Guid
organisationId
|
Returns
System.Threading.Tasks.Task<IOrganisation>
|
Implements
IOrganisationManager.FindByTrustedDomain(String)
Declaration
async Task<OrganisationKeys> IOrganisationManager.FindByTrustedDomain(string domainName)
Parameters
String
domainName
|
Returns
System.Threading.Tasks.Task<OrganisationKeys>
|