Example #1
0
        /// <summary>
        /// Получение списка параметров для квоты "мало" по классам услуг
        /// </summary>
        /// <param name="dc">Контекст базы данных</param>
        /// <returns></returns>
        public static Dictionary <uint, QuotaSmallServiceParams> GetQuotaSmallServiceParams(this MtSearchDbDataContext dc)
        {
            Dictionary <uint, QuotaSmallServiceParams> serviceSmallParams;
            const string hash = "ServiceSmallParams";

            if ((serviceSmallParams = CacheHelper.GetCacheItem <Dictionary <uint, QuotaSmallServiceParams> >(hash)) != default(Dictionary <uint, QuotaSmallServiceParams>))
            {
                return(serviceSmallParams);
            }

            serviceSmallParams = (from s in dc.GetAllServices()
                                  where (s.SV_KEY == 1 || s.SV_KEY == 3)
                                  select s
                                  )
                                 .ToDictionary(s => (uint)s.SV_KEY, s => new QuotaSmallServiceParams
            {
                AndParam     = s.SV_LittleAnd.HasValue && s.SV_LittleAnd.Value,
                PercentParam = (double?)s.SV_LittlePercent,
                PlaceParam   = (uint?)s.SV_LittlePlace
            });

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

            return(serviceSmallParams);
        }
Example #2
0
        /// <summary>
        /// Возвращает название класса услуги по значению enum
        /// </summary>
        /// <param name="dc">Контекст БД</param>
        /// <param name="serviceClass">Перечисление класса услуги</param>
        /// <returns></returns>
        public static string GetServiceClassName(this MtSearchDbDataContext dc, ServiceClass serviceClass)
        {
            var res = (from s in dc.GetAllServices()
                       where s.SV_KEY == (int)serviceClass
                       select s.SV_NAME)
                      .SingleOrDefault();

            return(res);
        }