public void SaveChanges(UserAccount account, ISettingsModel settings) { if (!isLoggedOut && !string.IsNullOrEmpty(account.Username)) { settings.AddOrUpdate("currentUser", account.Username); settings.SaveSettings(); this.SubmitChanges(); } }
public async Task<UserAccount> LoadCurrentUser(ISettingsModel settings) { string currentUser = settings.GetValueOrDefault<string>("currentUser", string.Empty); UserAccount currentAccount = UserAccounts .Where(item => item.Username.Equals(currentUser)) .SingleOrDefault(); if (currentAccount == null) { // return an anonymous, public user. settings.AddOrUpdate("currentUser", string.Empty); settings.SaveSettings(); currentAccount = new UserAccount(); } else { // attach tokens and favorites currentAccount = await AttachAssociationsAsync(currentAccount); if (!currentAccount.AsForumAccessToken().IsActiveAccount) { settings.AddOrUpdate("currentUser", string.Empty); settings.SaveSettings(); } } return currentAccount; }
public async Task SaveChangesAsync(UserAccount account, ISettingsModel settings) { if (!isLoggedOut && !string.IsNullOrEmpty(account.Username)) { settings.AddOrUpdate("currentUser", account.Username); settings.SaveSettings(); await StorageModelFactory.GetStorageModel().SaveToStorageAsync(ConnectionString, this); } }