Example #1
0
        /// <summary>
        /// Возвращает ключ и код национальной валюты
        /// </summary>
        /// <param name="dc"></param>
        /// <returns></returns>
        public static Tuple <int, string> GetNationalRateInfo(this MtSearchDbDataContext dc)
        {
            Tuple <int, string> result;

            var hash = String.Format("{0}", MethodBase.GetCurrentMethod().Name);

            if ((result = CacheHelper.GetCacheItem <Tuple <int, string> >(hash)) != null)
            {
                return(result);
            }

            var rates = dc.GetAllRatesList();

            result = (from r in rates
                      where r.RA_National == 1
                      select new Tuple <int, string>(r.ra_key, r.RA_CODE))
                     .SingleOrDefault();

            CacheHelper.AddCacheData(hash, result, new List <string>()
            {
                TableName
            }, Globals.Settings.Cache.LongCacheTimeout);

            return(result);
        }
Example #2
0
        /// <summary>
        /// Возвращает ключ валюты по ее коду
        /// </summary>
        /// <param name="dc">Контекст базы данных</param>
        /// <param name="rateCode">Код валюты</param>
        /// <returns></returns>
        public static int GetRateKeyByCode(this MtSearchDbDataContext dc, string rateCode)
        {
            int result;

            var hash = String.Format("{0}_{1}", MethodBase.GetCurrentMethod().Name, rateCode);

            if (CacheHelper.IsCacheKeyExists(hash))
            {
                result = CacheHelper.GetCacheItem <int>(hash);
                return(result);
            }

            var rates = dc.GetAllRatesList();

            result = (from r in rates
                      where r.RA_CODE == rateCode
                      select r.ra_key)
                     .SingleOrDefault();

            CacheHelper.AddCacheData(hash, result, new List <string>()
            {
                TableName
            }, Globals.Settings.Cache.LongCacheTimeout);

            return(result);
        }