Class ModuleManager
Provides the APIs for managing module in a persistance store.
Inherited Members
Namespace: IRM.AspNetCore.Identity
Assembly: IRM.AspNetCore.Identity.dll
Syntax
public class ModuleManager : IDisposable
Constructors
ModuleManager(IModuleStore, IEnumerable<IModuleValidator>, IHttpContextAccessor, ExtendedIdentityErrorDescriber, ILogger<ModuleManager>)
Constructs a new instance of ModuleManager.
Declaration
public ModuleManager(IModuleStore store, IEnumerable<IModuleValidator> moduleValidators, IHttpContextAccessor contextAccessor, ExtendedIdentityErrorDescriber errorDescriber, ILogger<ModuleManager> logger)
Parameters
IModuleStore
store
The persistence store the manager will operate over. |
IEnumerable<IModuleValidator>
moduleValidators
A collection of validators for modules. |
Microsoft.AspNetCore.Http.IHttpContextAccessor
contextAccessor
The accessor used to access the Microsoft.AspNetCore.Http.HttpContext. |
ExtendedIdentityErrorDescriber
errorDescriber
The ExtendedIdentityErrorDescriber used to provider error messages. |
Microsoft.Extensions.Logging.ILogger<ModuleManager>
logger
The logger used to log messages, warnings and errors. |
Properties
CancellationToken
The cancellation token used to cancel operations.
Declaration
protected virtual CancellationToken CancellationToken { get; }
Property Value
System.Threading.CancellationToken
|
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
|
ModuleValidators
Gets a list of validators for modules to call before persistence.
Declaration
public IEnumerable<IModuleValidator> ModuleValidators { get; }
Property Value
IEnumerable<IModuleValidator>
|
Store
Gets the persistence store this instance operates over.
Declaration
protected IModuleStore Store { get; }
Property Value
IModuleStore
|
Methods
AddRoleTemplatePermission(Module, Guid, String)
Adds the specified permission
to the template.
Declaration
public virtual Task<IdentityResult> AddRoleTemplatePermission(Module module, Guid roleTemplateId, string permission)
Parameters
Module
module
The Module to add a permission to role template. |
System.Guid
roleTemplateId
The role template id to add a permission to. |
String
permission
The permission to add. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult. |
BuyModuleAsync(Guid, Guid)
Buys the specified module for the specified tenant.
Declaration
public virtual async Task<IdentityResult> BuyModuleAsync(Guid moduleId, Guid tenantId)
Parameters
System.Guid
moduleId
The identity of the module. |
System.Guid
tenantId
The identity of the tenant. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The task object representing the asynchronous operation, with the IdentityResult representing the outcome of the operation. |
CreateAsync(Module)
Creates the specified module in the persistence store.
Declaration
public virtual async Task<IdentityResult> CreateAsync(Module module)
Parameters
Module
module
The module 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. |
CreateFunctionalityAsync(Module, Functionality)
Creates a new role template.
Declaration
public virtual async Task<IdentityResult> CreateFunctionalityAsync(Module module, Functionality functionality)
Parameters
Module
module
The Module to create a role template for. |
Functionality
functionality
The functionality to create. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult. |
CreateRoleTemplateAsync(Module, Guid, String, Boolean, Boolean)
Creates a new role template.
Declaration
public virtual async Task<IdentityResult> CreateRoleTemplateAsync(Module module, Guid id, string roleName, bool builtIn, bool addForNewUser)
Parameters
Module
module
The Module to create a role template for. |
System.Guid
id
The identifier for the Role template. Leave empty to autogenerate |
String
roleName
The unique name of the role. |
Boolean
builtIn
true if the role should be treated as a built-in role; otherwise false. |
Boolean
addForNewUser
true if the role automatically should be added for new users |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult. |
DeleteAsync(Module)
Deletes the specified module
.
Declaration
public virtual Task<IdentityResult> DeleteAsync(Module module)
Parameters
Module
module
The module 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. |
DeleteFunctionalityAsync(Module, Guid)
Deletes the specified role template.
Declaration
public virtual async Task<IdentityResult> DeleteFunctionalityAsync(Module module, Guid functionalityId)
Parameters
Module
module
The Module to delete a role template from. |
System.Guid
functionalityId
The functionality id to delete. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult. |
DeleteRoleTemplateAsync(Module, Guid)
Deletes the specified role template.
Declaration
public virtual async Task<IdentityResult> DeleteRoleTemplateAsync(Module module, Guid roleTemplateId)
Parameters
Module
module
The Module to delete a role template from. |
System.Guid
roleTemplateId
The role template id to delete. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult. |
Dispose()
Releases all resources used by the module manager.
Declaration
public void Dispose()
Implements
Dispose(Boolean)
Releases the unmanaged resources used by the role 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. |
Finalize()
Declaration
protected void Finalize()
FindBoughtFunctionalityAsync(Guid)
Finds and returns all modules and their functionalities, if any, for the specified tenantId
.
Declaration
public async Task<List<Module>> FindBoughtFunctionalityAsync(Guid tenantId)
Parameters
System.Guid
tenantId
The tenant ID to search for bought modules. |
Returns
System.Threading.Tasks.Task<List<Module>>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the modules and their functionalities for the specified |
FindBoughtModulesByTenantAsync(Guid)
Finds and returns all bought modules, if any, for the specified tenantId
.
Declaration
public virtual Task<List<BoughtModule>> FindBoughtModulesByTenantAsync(Guid tenantId)
Parameters
System.Guid
tenantId
The tenant ID to search for bought modules. |
Returns
System.Threading.Tasks.Task<List<BoughtModule>>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the bought module for the specified |
FindByIdAsync(Guid)
Finds and returns a module, if any, that has the specified moduleId
.
Declaration
public virtual Task<Module> FindByIdAsync(Guid moduleId)
Parameters
System.Guid
moduleId
The module ID to search for. |
Returns
System.Threading.Tasks.Task<Module>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the module matching the specified |
FindByNameAsync(String)
Finds and returns a module, if any, that has the specified module name.
Declaration
public virtual Task<Module> FindByNameAsync(string moduleName)
Parameters
String
moduleName
The module name to search for. |
Returns
System.Threading.Tasks.Task<Module>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the module matching the specified |
GetAllAsync(ModuleSearchQuery)
Gets all available modules.
Declaration
public virtual Task<QueryResult<Module>> GetAllAsync(ModuleSearchQuery query)
Parameters
ModuleSearchQuery
query
The ModuleSearchQuery used to limit the returned result. |
Returns
System.Threading.Tasks.Task<QueryResult<Module>>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing modules. |
GetAnyUnpayedModulesAsync<TUser>(TUser)
Gets if the tenant that the user belongs to has any unpayed modules.
Declaration
public virtual async Task<bool> GetAnyUnpayedModulesAsync<TUser>(TUser user)
where TUser : IMultitenantUser
Parameters
TUser
user
The user to check for unpayed modules. |
Returns
System.Threading.Tasks.Task<Boolean>
The System.Threading.Tasks.Task that represents the asynchronous operation, with true if there are unpayed modules or false otherwise. |
Type Parameters
TUser
The type of IMultitenantUser. |
RemoveTemplatePermission(Module, Guid, String)
Temoves the specified permission
from the template.
Declaration
public virtual Task<IdentityResult> RemoveTemplatePermission(Module module, Guid roleTemplateId, string permission)
Parameters
Module
module
The Module to remove a permission to role template. |
System.Guid
roleTemplateId
The role template id to add a permission to. |
String
permission
The permission to add. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult. |
SetOffline(Guid)
Sets the specified module offline.
Declaration
public virtual async Task<IdentityResult> SetOffline(Guid moduleId)
Parameters
System.Guid
moduleId
The identity of the module. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The task object representing the asynchronous operation, with the IdentityResult representing the outcome of the operation. |
SetOnline(Guid)
Sets the specified module online.
Declaration
public virtual async Task<IdentityResult> SetOnline(Guid moduleId)
Parameters
System.Guid
moduleId
The identity of the module. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The task object representing the asynchronous operation, with the IdentityResult representing the outcome of the operation. |
ThrowIfDisposed()
Throws System.ObjectDisposedException if this class is disposed.
Declaration
protected void ThrowIfDisposed()
UpdateAsync(Module)
Updates the specified module
.
Declaration
public virtual async Task<IdentityResult> UpdateAsync(Module module)
Parameters
Module
module
The module to updated. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult for the update. |
UpdateFunctionalityAsync(Module, Functionality)
Updates the specified role template.
Declaration
public virtual async Task<IdentityResult> UpdateFunctionalityAsync(Module module, Functionality functionality)
Parameters
Module
module
The Module to update a role template for. |
Functionality
functionality
The functionality to update. |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult. |
UpdateRoleTemplateAsync(Module, Guid, String, Boolean, Boolean)
Updates the specified role template.
Declaration
public virtual async Task<IdentityResult> UpdateRoleTemplateAsync(Module module, Guid roleTemplateId, string roleName, bool builtIn, bool addForNewUser)
Parameters
Module
module
The Module to update a role template for. |
System.Guid
roleTemplateId
The role template id to update. |
String
roleName
The unique name of the role. |
Boolean
builtIn
true if the role should be treated as a built-in role; otherwise false. |
Boolean
addForNewUser
true if the role automatically should be added for new users |
Returns
System.Threading.Tasks.Task<IdentityResult>
The System.Threading.Tasks.Task that represents the asynchronous operation, containing the IdentityResult. |
ValidateFunctionalityAsync(Module, Functionality)
Should return Microsoft.AspNetCore.Identity.IdentityResult.Success if validation is successful. This is called before saving the role template via CreateFunctionalityAsync(Module, Functionality) or UpdateFunctionalityAsync(Module, Functionality).
Declaration
protected virtual Task<IdentityResult> ValidateFunctionalityAsync(Module module, Functionality functionality)
Parameters
Module
module
The module. |
Functionality
functionality
|
Returns
System.Threading.Tasks.Task<IdentityResult>
A IdentityResult representing whether validation was successful. |
ValidateModuleAsync(Module)
Should return Microsoft.AspNetCore.Identity.IdentityResult.Success if validation is successful. This is called before saving the role via CreateAsync(Module) or UpdateAsync(Module).
Declaration
protected virtual async Task<IdentityResult> ValidateModuleAsync(Module module)
Parameters
Module
module
The module. |
Returns
System.Threading.Tasks.Task<IdentityResult>
A IdentityResult representing whether validation was successful. |
ValidateRoleTemplateAsync(Module, RoleTemplate)
Should return Microsoft.AspNetCore.Identity.IdentityResult.Success if validation is successful. This is called before saving the role template via
Declaration
protected virtual Task<IdentityResult> ValidateRoleTemplateAsync(Module module, RoleTemplate roleTemplate)
Parameters
Module
module
The module. |
RoleTemplate
roleTemplate
|
Returns
System.Threading.Tasks.Task<IdentityResult>
A IdentityResult representing whether validation was successful. |