public int?Resolve(DatabaseTest source, Test destination, int?member, ResolutionContext context)
        {
            var user = _context.GetCurrentUser();

            if (user.IsAdmin())
            {
                return(_repositoryTheme.GetCount(new ThemesByTestId(source.Id)));
            }

            if (user.IsLecturer())
            {
                var specification =
                    new ThemesByTestId(source.Id) &
                    new ThemesByLecturerId(user.Id);

                return(_repositoryTheme.GetCount(specification));
            }

            if (user.IsStudent())
            {
                var specification =
                    new ThemesByTestId(source.Id) &
                    new ThemesForStudents() &
                    new ThemesByStudentId(user.Id);

                return(_repositoryTheme.GetCount(specification));
            }

            return(null);
        }
        public async Task <PagedData <Theme> > GetThemesAsync(FilterTheme filter)
        {
            var user = await Context.GetCurrentUserAsync();

            if (user.IsAdmin())
            {
                var specification =
                    new ThemesByTestId(filter.TestId) &
                    new ThemesByDisciplineId(filter.DisciplineId);

                var(count, themes) = await _repositoryTheme.FindPaginatedAsync(specification, filter);

                return(new PagedData <Theme>(Mapper.Map <List <Theme> >(themes), count));
            }

            if (user.IsLecturer())
            {
                var specification =
                    new ThemesByTestId(filter.TestId) &
                    new ThemesByDisciplineId(filter.DisciplineId) &
                    new ThemesByLecturerId(user.Id);

                var(count, themes) = await _repositoryTheme.FindPaginatedAsync(specification, filter);

                return(new PagedData <Theme>(Mapper.Map <List <Theme> >(themes), count));
            }

            throw ExceptionHelper.NoAccess();
        }