コード例 #1
0
        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();
        }
コード例 #2
0
 public async Task <IActionResult> GetTestThemes([FromRoute] int id, [FromQuery] FilterTheme filter)
 {
     return(await Ok(() => _serviceTheme.GetThemesAsync(filter.SetTestId(id))));
 }
コード例 #3
0
 public async Task <IActionResult> GetThemes([FromQuery] FilterTheme filter)
 {
     return(await Ok(() => _serviceTheme.GetThemesAsync(filter)));
 }