public void SetProperty(string code, string value, string guid = "") { CoreManager mng = new CoreManager(); Guid userGuid = Guid.Empty; if (guid == "") { userGuid = mng.GetUserGuid(); } else { userGuid = new Guid(guid); } var prop = db.GetProfileProperty(code); if (prop == null) { prop = new as_profileProperties { id = 0, code = code, name = code }; db.SaveProfileProperty(prop); } var item = db.GetProfilePropertyValue(prop.id, userGuid); if (item != null) { item.value = value; db.SaveProfilePropertyValue(item); } else { item = new as_profilePropertyValues { id = 0, propertyID = prop.id, userGuid = userGuid, value = value }; db.SaveProfilePropertyValue(item); } string key = "as_profile_prop_code_" + code + "_user_" + userGuid; CacheManager.PurgeCacheItems(key); }
public string GetProperty(string code, string def, string guid = "") { string res = def; CoreManager mng = new CoreManager(); Guid userGuid = Guid.Empty; if (guid == "") { userGuid = mng.GetUserGuid(); } else { userGuid = new Guid(guid); } string key = "as_profile_prop_code_" + code + "_user_" + userGuid + "_def_" + def; if (CacheManager.EnableCaching && CacheManager.Cache[key] != null) { res = CacheManager.Cache[key].ToString(); } else { var item = db.GetProfileProperty(code); if (item != null) { var itemVal = db.GetProfilePropertyValue(item.id, userGuid); if (itemVal != null) { res = itemVal.value; } } CacheManager.CacheData(key, res); } return(res); }