コード例 #1
0
ファイル: UserViewModel.cs プロジェクト: weddingjuma/Guardian
        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);
                    }
                }
            }
        }
コード例 #2
0
ファイル: UserViewModel.cs プロジェクト: weddingjuma/Guardian
        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);
        }
コード例 #3
0
ファイル: UserViewModel.cs プロジェクト: weddingjuma/Guardian
        public void CreateDefaultUser()
        {
            UserTableEntity user = new UserTableEntity();

            //user.IsDataSynced = true;
            user.CurrentProfileId = "0";

            _dataContext.UserTable.InsertOnSubmit(user);
            _dataContext.SubmitChanges();

            this.User = user;
        }
コード例 #4
0
ファイル: UserViewModel.cs プロジェクト: weddingjuma/Guardian
        public void LoadUserData()
        {
            this.User = (from UserTableEntity u in _dataContext.UserTable
                         select u).FirstOrDefault();

            if (this.User == null)
            {
                CreateDefaultUser();
            }

            this.IsDataLoaded = true;
        }
コード例 #5
0
ファイル: UserViewModel.cs プロジェクト: weddingjuma/Guardian
        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);
        }
コード例 #6
0
ファイル: UserViewModel.cs プロジェクト: weddingjuma/Guardian
        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;
        }
コード例 #7
0
ファイル: UserViewModel.cs プロジェクト: weddingjuma/Guardian
        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!"));
            }
        }