Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        /// <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"));
        }
Exemplo n.º 3
0
        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);
        }