public async Task <ActionResult> GetRandomFromAll()
        {
            EnglishTextInfoModel englishText = await _randomTextInfoService.GetRandomInfoFromAllAsync();

            var englishTextViewModel = _mapper.Map <EnglishTextInfoViewModel>(englishText);

            return(Ok(englishTextViewModel));
        }
Example #2
0
        public async Task <IActionResult> GetInfoById(string id)
        {
            EnglishTextInfoModel englishText = await _textService.GetInfoByIdAsync(id);

            if (englishText == null)
            {
                return(NotFound());
            }

            var englishTextViewModel = _mapper.Map <EnglishTextInfoViewModel>(englishText);

            return(Ok(englishTextViewModel));
        }
        public async Task <ActionResult> FindRandomByFilter(
            [FromQuery] string phrase,
            [FromQuery] string[] textType,
            [FromQuery] EnglishLevelViewModel[] englishLevel)
        {
            var englishLevelModels = _mapper.Map <EnglishLevelModel[]>(englishLevel);

            EnglishTextInfoModel englishText = await _randomTextInfoService.FindRandomInfoByFiltersAsync(phrase, textType, englishLevelModels);

            if (englishText == null)
            {
                return(NotFound());
            }

            var englishTextViewModel = _mapper.Map <EnglishTextInfoViewModel>(englishText);

            return(Ok(englishTextViewModel));
        }