public async Task <JsonResult> GetLastWordsAsync(string leng, int?limitTo = 6) { var wordStatistics = await _firebaseService.GetStatisticsAsync(UserId, limitTo); var wordNames = wordStatistics .OrderBy(s => s.Timestamp) .Select(s => s.Name) .ToArray(); var wordInfo = await _firebaseService.GetWordsAsync(wordNames); int i = 0; var result = wordInfo.Select(s => { var res = Mapper.Map <WordModel>(s); res.Name = wordNames[i++]; string translation; if (s.Translations != null && s.Translations.TryGetValue(leng, out translation)) { res.Translation = translation; } return(res); }); return(GenerateJsonResult(result)); }
public async Task GetStatisticsShouldSucceed() { const int expectedLen = 3; var words = await _service.GetStatisticsAsync("115787596179138188666", expectedLen); Assert.IsNotNull(words); Assert.AreEqual(expectedLen, words.Count()); }