public static void SaveSettings(UserSettings settings, Action <string, object> SetSessionValue, bool persist) { SetSessionValue("settings", settings); MembershipUser account = System.Web.Security.Membership.GetUser(Thread.CurrentPrincipal.Identity.Name); DatabaseUserProfile profile = ProfileBase.Create(account.UserName) as DatabaseUserProfile; profile.DatabaseSettings = settings; profile.Save(); }
public static UserSettings LoadSettings(Func <string, object> GetSessionValue) { if (string.IsNullOrEmpty(Thread.CurrentPrincipal.Identity.Name)) { return(new UserSettings()); } UserSettings settings = null; if (GetSessionValue("settings") != null) { settings = (UserSettings)GetSessionValue("settings"); } else { MembershipUser account = System.Web.Security.Membership.GetUser(Thread.CurrentPrincipal.Identity.Name); DatabaseUserProfile profile = ProfileBase.Create(account.UserName) as DatabaseUserProfile; if (profile.DatabaseSettings != null) { settings = profile.DatabaseSettings as UserSettings; } } return(settings ?? new UserSettings()); }