private void HandleUserChanged(CommunityManagerChanged message, LinkHeader user)
        {
            GroupContact groupContact = this._contacts.FirstOrDefault <GroupContact>((Func <GroupContact, bool>)(c => c.user_id == message.ManagerId));

            if (message.Role != CommunityManagementRole.Unknown)
            {
                user.User.Role = message.Role;
                user.AddToManagersVisibility = Visibility.Collapsed;
                user.EditVisibility          = Visibility.Visible;
                user.BlockVisibility         = Visibility.Collapsed;
                if (groupContact != null)
                {
                    if (message.IsContact)
                    {
                        groupContact.desc  = message.Position;
                        groupContact.email = message.Email;
                        groupContact.phone = message.Phone;
                    }
                    else
                    {
                        this._contacts.Remove(groupContact);
                    }
                }
                else if (message.IsContact)
                {
                    this._contacts.Add(new GroupContact()
                    {
                        user_id = user.Id,
                        desc    = message.Position,
                        email   = message.Email,
                        phone   = message.Phone
                    });
                }
            }
            else
            {
                user.User.Role = message.Role;
                user.AddToManagersVisibility = Visibility.Visible;
                user.EditVisibility          = Visibility.Collapsed;
                user.BlockVisibility         = Visibility.Visible;
                if (groupContact != null)
                {
                    this._contacts.Remove(groupContact);
                }
            }
            user.UpdateRole(message.Role);
        }
        public void Handle(CommunityManagerChanged message)
        {
            if (message.CommunityId != this.CommunityId)
            {
                return;
            }
            LinkHeader user1 = this.All.Collection.FirstOrDefault <LinkHeader>((Func <LinkHeader, bool>)(u => u.Id == message.ManagerId));

            if (user1 != null)
            {
                this.HandleUserChanged(message, user1);
            }
            LinkHeader user2 = this.Unsure.Collection.FirstOrDefault <LinkHeader>((Func <LinkHeader, bool>)(u => u.Id == message.ManagerId));

            if (user2 != null)
            {
                this.HandleUserChanged(message, user2);
            }
            LinkHeader user3 = this.Friends.Collection.FirstOrDefault <LinkHeader>((Func <LinkHeader, bool>)(u => u.Id == message.ManagerId));

            if (user3 != null)
            {
                this.HandleUserChanged(message, user3);
            }
            GenericCollectionViewModel2 <VKList <User>, LinkHeader> searchViewModel = this.SearchViewModel;

            if ((searchViewModel != null ? searchViewModel.GroupedCollection : (ObservableCollection <Group <LinkHeader> >)null) == null || this.SearchViewModel.GroupedCollection.Count <= 1)
            {
                return;
            }
            LinkHeader user4 = this.SearchViewModel.GroupedCollection[1].FirstOrDefault <LinkHeader>((Func <LinkHeader, bool>)(u => u.Id == message.ManagerId));

            if (user4 == null)
            {
                return;
            }
            this.HandleUserChanged(message, user4);
        }
Exemplo n.º 3
0
        public void Handle(CommunityManagerChanged message)
        {
            if (message.CommunityId != this.CommunityId)
            {
                return;
            }
            Execute.ExecuteOnUIThread((Action)(() =>
            {
                if (message.EditingMode == EditingMode.Adding)
                {
                    User user = message.User;
                    user.Role = message.Role;
                    LinkHeader linkHeader = new LinkHeader(user, (Action <FrameworkElement>)(e =>
                    {
                        GroupContact groupContact = this._contacts.FirstOrDefault <GroupContact>((Func <GroupContact, bool>)(c => c.user_id == user.id));
                        Navigator.Current.NavigateToCommunityManagementManagerEditing(this.CommunityId, this._communityType, user, groupContact != null, groupContact != null ? groupContact.desc : (string)null, groupContact != null ? groupContact.email : (string)null, groupContact != null ? groupContact.phone : (string)null);
                    }), "/Resources/Edit32px.png");
                    if (message.IsContact)
                    {
                        this._contacts.Add(new GroupContact()
                        {
                            user_id = message.ManagerId,
                            desc = message.Position,
                            email = message.Email,
                            phone = message.Phone
                        });
                    }
                    this.Managers.Insert(linkHeader, 0);
                }
                else
                {
                    LinkHeader linkHeader = this.Managers.Collection.FirstOrDefault <LinkHeader>((Func <LinkHeader, bool>)(m => m.Id == message.ManagerId));
                    if (linkHeader == null)
                    {
                        return;
                    }
                    if (message.Role == CommunityManagementRole.Unknown)
                    {
                        this.Managers.Delete(linkHeader);
                    }
                    else
                    {
                        switch (message.Role)
                        {
                        case CommunityManagementRole.Moderator:
                            linkHeader.Description = CommonResources.CommunityManager_Moderator;
                            break;

                        case CommunityManagementRole.Editor:
                            linkHeader.Description = CommonResources.CommunityManager_Editor;
                            break;

                        case CommunityManagementRole.Administrator:
                            linkHeader.Description = CommonResources.CommunityManager_Administrator;
                            break;
                        }
                        linkHeader.User.Role = message.Role;
                        GroupContact groupContact = this._contacts.FirstOrDefault <GroupContact>((Func <GroupContact, bool>)(c => c.user_id == message.ManagerId));
                        if (!message.IsContact)
                        {
                            if (groupContact == null)
                            {
                                return;
                            }
                            this._contacts.Remove(groupContact);
                        }
                        else if (groupContact != null)
                        {
                            groupContact.desc = message.Position;
                            groupContact.email = message.Email;
                            groupContact.phone = message.Phone;
                        }
                        else
                        {
                            this._contacts.Add(new GroupContact()
                            {
                                user_id = message.ManagerId,
                                desc = message.Position,
                                email = message.Email,
                                phone = message.Phone
                            });
                        }
                    }
                }
            }));
        }
        public void SaveChanges(bool isRemoving, NavigationService navigationService)
        {
            CommunityManagementRole role = CommunityManagementRole.Unknown;

            if (!isRemoving)
            {
                bool?moderatorSelected = this.IsModeratorSelected;
                bool flag1             = true;
                if ((moderatorSelected.GetValueOrDefault() == flag1 ? (moderatorSelected.HasValue ? 1 : 0) : 0) != 0)
                {
                    role = CommunityManagementRole.Moderator;
                }
                bool?isEditorSelected = this.IsEditorSelected;
                bool flag2            = true;
                if ((isEditorSelected.GetValueOrDefault() == flag2 ? (isEditorSelected.HasValue ? 1 : 0) : 0) != 0)
                {
                    role = CommunityManagementRole.Editor;
                }
                bool?administratorSelected = this.IsAdministratorSelected;
                bool flag3 = true;
                if ((administratorSelected.GetValueOrDefault() == flag3 ? (administratorSelected.HasValue ? 1 : 0) : 0) != 0)
                {
                    role = CommunityManagementRole.Administrator;
                }
            }
            EditingMode editingMode = this._isEditing ? EditingMode.Editing : EditingMode.Adding;

            if (isRemoving)
            {
                editingMode = EditingMode.Removing;
            }
            this.SetInProgress(true, "");
            this.IsFormEnabled = false;
            GroupsService current1    = GroupsService.Current;
            long          communityId = this._communityId;
            long          id          = this._manager.id;
            int           num1        = (int)role;
            bool?         isContact1  = this.IsContact;
            bool          flag4       = true;
            int           num2        = isContact1.GetValueOrDefault() == flag4 ? (isContact1.HasValue ? 1 : 0) : 0;
            string        position1   = this.Position;
            string        email1      = this.Email;
            string        phone1      = this.Phone;
            Action <BackendResult <int, ResultCode> > callback = (Action <BackendResult <int, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() =>
            {
                if (result.ResultCode == ResultCode.Succeeded)
                {
                    EventAggregator current2 = EventAggregator.Current;
                    CommunityManagerChanged communityManagerChanged = new CommunityManagerChanged();
                    communityManagerChanged.CommunityId = this._communityId;
                    communityManagerChanged.ManagerId = this._manager.id;
                    communityManagerChanged.EditingMode = editingMode;
                    communityManagerChanged.Role = role;
                    bool?isContact2 = this.IsContact;
                    bool flag1 = true;
                    int num3 = isContact2.GetValueOrDefault() == flag1 ? (isContact2.HasValue ? 1 : 0) : 0;
                    communityManagerChanged.IsContact = num3 != 0;
                    string position2 = this.Position;
                    communityManagerChanged.Position = position2;
                    string email2 = this.Email;
                    communityManagerChanged.Email = email2;
                    string phone2 = this.Phone;
                    communityManagerChanged.Phone = phone2;
                    User manager = this._manager;
                    communityManagerChanged.User = manager;
                    current2.Publish((object)communityManagerChanged);
                    if (!this._isEditing && this._fromPicker)
                    {
                        navigationService.RemoveBackEntry();
                    }
                    if (this._manager.id != VKClient.Common.Library.AppGlobalStateManager.Current.LoggedInUserId || role == CommunityManagementRole.Administrator)
                    {
                        Navigator.Current.GoBack();
                    }
                    else if (role != CommunityManagementRole.Unknown)
                    {
                        Navigator.Current.NavigateToCommunityManagement(this._communityId, this._communityType, false);
                        this._navigationService.RemoveBackEntry();
                        this._navigationService.RemoveBackEntry();
                        this._navigationService.RemoveBackEntry();
                    }
                    else
                    {
                        this._navigationService.RemoveBackEntry();
                        this._navigationService.RemoveBackEntry();
                        Navigator.Current.GoBack();
                    }
                }
                else
                {
                    this.SetInProgress(false, "");
                    this.IsFormEnabled = true;
                    VKClient.Common.UC.GenericInfoUC.ShowBasedOnResult((int)result.ResultCode, "", null);
                }
            })));

            current1.EditManager(communityId, id, (CommunityManagementRole)num1, num2 != 0, position1, email1, phone1, callback);
        }