Ejemplo n.º 1
0
        /// <inheritdoc />
        public Task <IEnumerable <UserSession> > GetUserSessionsAsync(UserSessionsFilter filter)
        {
            filter.Validate();

            var query = _store.Values.AsQueryable();

            if (!String.IsNullOrWhiteSpace(filter.SubjectId))
            {
                query = query.Where(x => x.SubjectId == filter.SubjectId);
            }
            if (!String.IsNullOrWhiteSpace(filter.SessionId))
            {
                query = query.Where(x => x.SessionId == filter.SessionId);
            }

            var results = query.Select(x => x.Clone()).ToArray().AsEnumerable();

            return(Task.FromResult(results));
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public Task DeleteUserSessionsAsync(UserSessionsFilter filter)
        {
            filter.Validate();

            var query = _store.Values.AsQueryable();

            if (!String.IsNullOrWhiteSpace(filter.SubjectId))
            {
                query = query.Where(x => x.SubjectId == filter.SubjectId);
            }
            if (!String.IsNullOrWhiteSpace(filter.SessionId))
            {
                query = query.Where(x => x.SessionId == filter.SessionId);
            }

            var keys = query.Select(x => x.Key).ToArray();

            foreach (var key in keys)
            {
                _store.TryRemove(key, out _);
            }

            return(Task.CompletedTask);
        }