Ejemplo n.º 1
0
        public static void SetValue(string category, string section, string key, object value)
        {
            var db = new ResourcesModelContainer();

            db.Settings.MergeOption = System.Data.Objects.MergeOption.OverwriteChanges;
            var item = db.Settings.FirstOrDefault(x => x.CultureCode == "en" & x.Category == category & x.Section == section & x.KeyName == key);

            if (item == null)
            {
                item          = new Setting();
                item.Category = category;
                item.Section  = section;
                item.KeyName  = key;
                db.Settings.AddObject(item);
            }
            item.KeyValue = value.ToString();
            if (value == null)
            {
                item.KeyType = "";
            }
            else
            {
                item.KeyType = value.GetType().Name;
            }
            db.SaveChanges();
        }
Ejemplo n.º 2
0
        public static string GetValue(string category, string section, string key)
        {
            var db = new ResourcesModelContainer();

            db.Settings.MergeOption = System.Data.Objects.MergeOption.OverwriteChanges;
            var item = db.Settings.FirstOrDefault(x => x.CultureCode == "en" & x.Category == category & x.Section == section & x.KeyName == key);

            return(item == null ? null : item.KeyValue);
        }
Ejemplo n.º 3
0
        public static List <Setting> GetTransforms(string culture, string category, string section)
        {
            culture  = culture ?? "";
            category = category ?? "";
            section  = section ?? "";
            var db    = new ResourcesModelContainer();
            var query = from item in db.Settings where ((culture == string.Empty) || item.CultureCode == culture) && ((category == string.Empty) || item.Category == category) && ((section == string.Empty) || item.Section == section) orderby item.KeyName select item;

            return(query.ToList());
        }