Ejemplo n.º 1
0
        public async Task <string> GetErrText(int error)
        {
            string key         = ECacheKey.ErrorInfo.ToString();
            var    cachedData  = _distributedCache.GetString(key);
            var    lstAllError = new List <ErrorInfo>();

            if (cachedData != null && cachedData != "null")
            {
                lstAllError = JsonConvert.DeserializeObject <List <ErrorInfo> >(cachedData);
            }
            else
            {
                lstAllError = await _moduleService.GetAllError();

                RedisUtils.SetCacheData(_distributedCache, _Configuration, lstAllError, key);
            }
            if (lstAllError != null && lstAllError.Any())
            {
                var err = lstAllError.Where(x => x.ErrorCode == error);
                if (err != null && err.Any())
                {
                    return(err.First().ErrorName);
                }
            }

            return("Không tìm thấy lỗi");
        }