示例#1
0
 public void SaveChanges(UserAccount account, ISettingsModel settings)
 {
     if (!isLoggedOut && !string.IsNullOrEmpty(account.Username))
     {
         settings.AddOrUpdate("currentUser", account.Username);
         settings.SaveSettings();
         this.SubmitChanges();
     }
 }
示例#2
0
        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;
        }
示例#3
0
 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);
     }
 }