Exemplo n.º 1
0
        public async Task <string> GetTextLang(string text)
        {
            string key           = ECacheKey.LanguageInfo.ToString();
            var    cachedData    = _distributedCache.GetString(key);
            var    lsAllLanguage = new List <LanguageInfo>();

            if (cachedData != null && cachedData != "null")
            {
                lsAllLanguage = JsonConvert.DeserializeObject <List <LanguageInfo> >(cachedData);
            }
            else
            {
                lsAllLanguage = await _moduleService.GetAllTextLanguage();

                RedisUtils.SetCacheData(_distributedCache, _Configuration, lsAllLanguage, key);
            }
            if (lsAllLanguage != null && lsAllLanguage.Any())
            {
                var lang = lsAllLanguage.Where(x => x.LanguageName == "DEFERROR$" + text);
                if (lang != null && lang.Any())
                {
                    return(lang.First().LanguageValue);
                }
            }
            return(text);
        }