private static async Task <AuthorisationResult> FailOnFirstCall() { await Task.CompletedTask; var result = _hasBeenCalled ? AuthorisationResult.Success() : AuthorisationResult.Fail("This query will fail the first time you call it, try again."); _hasBeenCalled = true; return(result); }
/// <summary> /// A contrived authorisation policy function /// </summary> /// <returns></returns> private static async Task <AuthorisationResult> WeekendOnlyPolicy() { var isWeekend = DateTime.Today.DayOfWeek == DayOfWeek.Saturday || DateTime.Today.DayOfWeek == DayOfWeek.Sunday; //This isn't really an async method await Task.CompletedTask; return(isWeekend ? AuthorisationResult.Success() : AuthorisationResult.Fail("This query can only be used on a Saturday or Sunday")); }
private static async Task <AuthorisationResult> FailOnFirstCall() { await Task.CompletedTask; var result = _hasBeenCalled ? AuthorisationResult.Success() : AuthorisationResult.Fail("This query can only be used on a Saturday or Sunday"); _hasBeenCalled = true; return(result); }