public static void RestoreAllProfiles(ObservableCollection <SOS.Phone.MembershipServiceRef.Profile> profiles) { if (profiles != null && profiles.Count > 0) { UserTableEntity user = new UserTableEntity(); user.UserId = profiles[0].UserID.ToString(); user.Name = profiles[0].Name; user.LiveEmail = profiles[0].Email; user.LiveAuthId = Globals.User.LiveAuthId; user.CurrentProfileId = profiles[0].ProfileID.ToString(); user.FBAuthId = profiles[0].FBAuthID; App.CurrentUser.UpdateUser(user); App.MyProfiles.RestoreProfiles(profiles); App.MyBuddies.DeleteAllBuddies(); App.MyGroups.DeleteAllGroups(); var allBuddies = new ObservableCollection <MembershipServiceRef.Buddy>(); var allGroups = new ObservableCollection <MembershipServiceRef.Group>(); foreach (var profile in profiles) { if (profile.MyBuddies != null) { App.MyBuddies.RestoreProfileBuddies(profile.ProfileID.ToString(), profile.MyBuddies); } if (profile.AscGroups != null) { App.MyGroups.RestoreProfileGroups(profile.ProfileID.ToString(), profile.AscGroups); } } } }
public MembershipServiceRef.Profile ConvertUser(UserTableEntity user) { MembershipServiceRef.Profile profile = new MembershipServiceRef.Profile(); profile.UserID = Convert.ToInt64(user.UserId); profile.Name = user.Name; profile.Email = user.LiveEmail; profile.LiveDetails = new MembershipServiceRef.LiveCred(); profile.FBAuthID = user.FBAuthId; return(profile); }
public void CreateDefaultUser() { UserTableEntity user = new UserTableEntity(); //user.IsDataSynced = true; user.CurrentProfileId = "0"; _dataContext.UserTable.InsertOnSubmit(user); _dataContext.SubmitChanges(); this.User = user; }
public void LoadUserData() { this.User = (from UserTableEntity u in _dataContext.UserTable select u).FirstOrDefault(); if (this.User == null) { CreateDefaultUser(); } this.IsDataLoaded = true; }
public UserTableEntity ConvertUser(MembershipServiceRef.Profile profile) { UserTableEntity user = new UserTableEntity(); user.UserId = profile.UserID.ToString(); user.Name = profile.Name; user.LiveEmail = profile.Email; user.LiveAuthId = Globals.User.LiveAuthId; user.FBAuthId = profile.FBAuthID; user.CurrentProfileId = profile.ProfileID.ToString(); return(user); }
public void UpdateUser(UserTableEntity user) { UserTableEntity localUser = (from UserTableEntity u in _dataContext.UserTable select u).FirstOrDefault(); localUser.UserId = user.UserId; localUser.Name = user.Name; localUser.LiveEmail = user.LiveEmail; localUser.LiveAuthId = Globals.User.LiveAuthId; if (user.CurrentProfileId != null) { localUser.CurrentProfileId = user.CurrentProfileId; } localUser.FBAuthId = user.FBAuthId; _dataContext.SubmitChanges(); this.User = localUser; }
public void SaveUserSetting(UserSetting setting, string value) { try { UserTableEntity user = this.User; switch (setting) { case UserSetting.UserId: user.UserId = value; break; case UserSetting.Name: user.Name = value; break; case UserSetting.Email: user.LiveEmail = value; break; case UserSetting.CurrentProfileID: user.CurrentProfileId = value; break; case UserSetting.FBAuthID: user.FBAuthId = value; break; default: break; } //Update the local storage with the new setting value this.UpdateUser(user); if (Globals.IsRegisteredUser && !(setting == UserSetting.CurrentProfileID || setting == UserSetting.UserId)) { App.MyProfiles.UpdateIsDataSynced(false); } } catch (Exception) { Deployment.Current.Dispatcher.BeginInvoke(() => Globals.DisplayToast(CustomMessage.UnableToSaveSettingText, "basicWrap", "Oops!")); } }