public async Task UpdateUsersAndRoles()
 {
     if ((DateTime.UtcNow - _lastCacheUpdated).TotalSeconds > 30)
     {
         _usersCache       = (await _usersRepository.GetAllAsync()).ToDictionary(itm => itm.Id);
         _rolesCache       = (await _rolesRepository.GetAllRolesAsync()).Select(BackofficeUserRole.Create).Cast <IBackofficeUserRole>().ToArray();
         _lastCacheUpdated = DateTime.UtcNow;
     }
 }
Beispiel #2
0
        public async Task <UserRolesPair> GetUserRolesPair()
        {
            string userId = GetUserId();

            var result = new UserRolesPair
            {
                User  = await UsersRepository.GetAsync(userId),
                Roles = (await UserRolesRepository.GetAllRolesAsync()).ToArray()
            };

            return(result);
        }