Class DelegateCondition<TModel, TUser>
Condition that uses a delegate to check if it has been met
Implements
ICondition<TModel, TUser>
Namespace: Seltzr.Conditions
Assembly: Seltzr.dll
Syntax
C#
public class DelegateCondition<TModel, TUser> : ICondition<TModel, TUser> where TModel : class where TUser : class
Type Parameters
TModel
The type of model in the dataset
TUser
The type of authenticated user
Constructors
|
Improve this Doc
View Source
DelegateCondition(Func<IApiContext<TModel, TUser>, IQueryable<TModel>, Task<Boolean>>, String)
Initializes a new instance of the DelegateCondition<TModel, TUser> class.
C#
public DelegateCondition(Func<IApiContext<TModel, TUser>, IQueryable<TModel>, Task<bool>> conditionDelegate, string failureMessage = null)
Parameters
conditionDelegate
Func<IApiContext<TModel, TUser>, IQueryable<TModel>, Task<Boolean>>
The delegate to use to check the status of the condition
failureMessage
String
The message of the exception to throw when the condition is not met
Properties
Gets a message indicating why the condition might have failed
C#
public string FailureMessage { get; }
Property Value
StringMethods
Verifies that the current request meets a condition
C#
public Task<bool> VerifyAsync(IApiContext<TModel, TUser> context, IQueryable<TModel> dataset)
Parameters
context
IApiContext<TModel, TUser>
The current API context
dataset
IQueryable<TModel>
The current dataset to be filtered
Returns
true if the request should continue, false otherwise