internal UserSecurity CreateNewModel() { var userPassport = new UserPassportTest().CreateNewModel(); var ignores = ignoreProperties.Split(','); var model = new UserSecurity(); TestHelper.FillRndProperties(model, ignores); model.PassportId = userPassport.PassportId; userPassport.UserSecurity = model; var saveResult = model.Save(); Assert.IsTrue(saveResult); return(model); }
public void SavePrivacy() { Boolean isUserPrivacyClose = Component.IsClose(typeof(UserPrivacy)); if (isUserPrivacyClose) { echo("对不起,本功能已经停用"); return; } //--------------------------------------------------------- User user = ctx.owner.obj as User; if (user == null) { echoRedirect(lang("exUser")); return; } Dictionary <string, int> settings = UserSecurity.GetSettingsAll(user); Dictionary <string, int> values = new Dictionary <string, int>(); foreach (KeyValuePair <string, int> s in settings) { int val = UserPrivacy.GetDefaultValue(); if (ctx.PostHas(s.Key)) { val = ctx.PostInt(s.Key); } values.Add(s.Key, val); } String settingsStr = UserSecurity.Save(values); user.Security = settingsStr; db.update(user, "Security"); echoRedirect(lang("opok")); }