Ejemplo n.º 1
0
        public async Task <IEnumerable <NewWord> > GetNewWordsAsync()
        {
            IEnumerable <NewWord> result = _cachedService.GetCachedData();

            if (result == null)
            {
                result = await _wordService.GetNewWords();

                _cachedService.SaveToCached(result);
            }
            return(result);
        }
Ejemplo n.º 2
0
        public IEnumerable <ExampleDto> GetExamples()
        {
            var examples = _cachedService.GetCachedData();

            if (examples == null)
            {
                examples = _mapper.Map <IEnumerable <ExampleDto> >(_exampleService.Filter(x => true));
                if (examples != null)
                {
                    _cachedService.SaveToCached(examples);
                }
            }
            return(examples.OrderByDescending(x => x.CreatedAt).AsEnumerable() ?? new List <ExampleDto>());
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> IndexAsync(string searchValue)
        {
            IEnumerable <NewWord> result = _cachedService.GetCachedData();

            if (result == null)
            {
                result = await _wordService.GetNewWords();

                _cachedService.SaveToCached(result);
            }
            return(View(new ListWordViewDto {
                Words = result.ToList()
            }));
        }
Ejemplo n.º 4
0
        public async System.Threading.Tasks.Task <IActionResult> IndexAsync()
        {
            var examples = _cachedService.GetCachedData();

            if (examples == null)
            {
                examples = _mapper.Map <IEnumerable <ExampleDto> >(await _exampleService.Filter(x => true));
                if (examples != null)
                {
                    _cachedService.SaveToCached(examples);
                }
            }
            var exampleIds = examples.Select(x => x.Id.ToString()).ToList();
            var words      = await _wordService.Filter(x => x.IsNew && x.ExampleIds.Any(id => exampleIds.Contains(id)));

            foreach (var example in examples)
            {
                example.Words = _mapper.Map <IEnumerable <Word>, IEnumerable <WordDto> >(words.Where(x => x.ExampleIds.Contains(example.Id))).ToList();
            }
            return(View(new ListExampleViewDto
            {
                Examples = examples.OrderByDescending(x => x.CreatedAt).AsEnumerable() ?? new List <ExampleDto>()
            }));
        }