/// <summary>
        ///
        /// </summary>
        /// <param name="isGroupContactsList">If true provide button to remove user from a group</param>
        /// <param name="isInviteList">If true provide button to invite user to a group</param>
        public ContactsListViewModel(bool isGroupContactsList = false, bool isInviteList = false, bool areYouAdmin = false, bool isYourContactsList = false)
        {
            IsGroupContactsList = isGroupContactsList;
            IsInviteList        = isInviteList;
            AreYouAdmin         = areYouAdmin;
            IsYourContactsList  = isYourContactsList;

            //Add event handler
            UnitOfWork.AddUserInfoUpdatedHandler((sender, args) => OnContactsListChanged(sender, args));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="contacts">contacts to add</param>
        /// <param name="isGroupContactsList">If true provide button to remove user from a group</param>
        /// <param name="isInviteList">If true provide button to invite user to a group</param>
        public ContactsListViewModel(List <Contact> contacts, bool isGroupContactsList = false, bool isInviteList = false, bool areYouAdmin = false, bool isYourContactsList = false)
        {
            IsGroupContactsList = isGroupContactsList;
            IsInviteList        = isInviteList;
            AreYouAdmin         = areYouAdmin;
            IsYourContactsList  = isYourContactsList;

            //Add event handler
            UnitOfWork.AddUserInfoUpdatedHandler((sender, args) => OnContactsListChanged(sender, args));

            foreach (var contact in contacts)
            {
                Items.Add(new ContactsListItemViewModel(contact, isGroupContactsList, isInviteList, areYouAdmin));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates group info page
        /// </summary>
        /// <param name="contact">Contact to display info</param>
        public InfoGroupControlViewModel()
        {
            //Setup handlers
            UnitOfWork.Database.GroupsTableRepo.AddDataChangedHandler((sender, args) => OnGroupUpdates(sender, args));
            UnitOfWork.Database.MessagesTableRepo.AddDataChangedHandler((sender, args) => OnMessageUpdates(sender, args));
            UnitOfWork.AddUserInfoUpdatedHandler((sender, args) => OnPropertyChanged("IsYourGroup"));
            ApplicationService.GetChatViewModel.OnCurrentChatChanged((sender, args) => loadInfo(args));


            ChangeGroupPhoto = new RelayCommand(changeGroupPhoto);
            ChangeGroupInfo  = new RelayCommandParametrized((data) => changeGroupInfo(data));
            DeleteGroup      = new RelayCommand(deleteGroup);

            //Load data
            loadInfo(ApplicationService.GetCurrentChoosenChat);
        }
Exemplo n.º 4
0
        async void loadInfo(Contact contact)
        {
            if (contact == null)
            {
                return;
            }

            //Set user info
            UserInfo = contact;

            //If it's your account, than add contacts list
            if (IsYourAccaunt)
            {
                //Add on user data changed handler
                UnitOfWork.AddUserInfoUpdatedHandler((sender, args) => OnUserUpdates(sender, args));

                //Load contacts info
                var contactsList = await UnitOfWork.GetUsersInfo(new List <int>(UnitOfWork.User.contactsIdList));

                if (contactsList != null)
                {
                    ContactsList = new ContactsListViewModel(contactsList, false, false, false, true);
                }
            }

            //If it's not your account, add groups list
            else
            {
                //Make request to the server and get groups list
                GroupsList = new GroupsListViewModel(await UnitOfWork.GetUserGroupsInfo(UserInfo));
            }


            //Update UI
            OnPropertyChanged("UserName");
            OnPropertyChanged("Bio");
            OnPropertyChanged("Email");
            OnPropertyChanged("IsYourContact");
            OnPropertyChanged("IsYourAccaunt");
            OnPropertyChanged("GroupsList");
        }