예제 #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)));
 }