Inheritance: INotifyPropertyChanged
        private async Task DoSendContact(UserModel user) {
            if (!(dialogToReturn is DialogModelPlain))
                return;

            InputPeer ip = dialogToReturn.InputPeer;
            InputMedia media = TL.inputMediaContact(user.PhoneNumber, user.FirstName, user.LastName);

            DialogModelPlain dialog = (DialogModelPlain) dialogToReturn;
            await dialog.SendMedia(media);
        }
        protected override void OnNavigatedTo(NavigationEventArgs e) {
            base.OnNavigatedTo(e);

            string uriParam = "";

            if (NavigationContext.QueryString.TryGetValue("userId", out uriParam)) {
                model = TelegramSession.Instance.GetUser(int.Parse(uriParam));
            } else {
                logger.error("Unable to get model id from navigation");
            }

            UpdateDataContext();
        }
        public PinchAndZoom() {
            InitializeComponent();

            media = MediaTransitionHelper.Instance.Media;
            
            if (media.Constructor == Constructor.messageMediaPhoto) {
                ImageViewportElement.Visibility = Visibility.Visible;
                PlaybackControls.Visibility = Visibility.Collapsed;

                MessageMediaPhotoConstructor cons = (MessageMediaPhotoConstructor) media;

                if (cons.photo.Constructor == Constructor.photoEmpty) {

                } else if (cons.photo.Constructor == Constructor.photo) {
                    PhotoConstructor photoConstructor = (PhotoConstructor) cons.photo;
                    author = TelegramSession.Instance.GetUser(photoConstructor.user_id);
                    MetaInfoAuthor.Text = author.FullName;
                    MetaInfoDate.Text = Formatters.FormatDialogDateTimestampUnix(photoConstructor.date);
                }

                DoLoadPhoto();
                return;
            } else if (media.Constructor == Constructor.messageMediaVideo) {
                ImageViewportElement.Visibility = Visibility.Collapsed;
                PlaybackControls.Visibility = Visibility.Visible;
                VideoPlayerElement.Visibility = Visibility.Visible;
                PlaybackButton.Visibility = Visibility.Visible;

                MessageMediaVideoConstructor cons = (MessageMediaVideoConstructor) media;

                if (cons.video.Constructor == Constructor.videoEmpty) {

                }
                else if (cons.video.Constructor == Constructor.video) {
                    VideoConstructor videoConstructor = (VideoConstructor) cons.video;
                    author = TelegramSession.Instance.GetUser(videoConstructor.user_id);

                    MetaInfoAuthor.Text = author.FullName;
                    MetaInfoDate.Text = Formatters.FormatDialogDateTimestampUnix(videoConstructor.date);
                }

                VideoPlayerElement.MediaEnded += delegate {
                    PlaybackButton.Visibility = Visibility.Visible;
                };
            }
            else {
                return;
            }

        }
 private void OnUserSelected(object sender, UserModel usermodel) {
     NavigationService.Navigate(new Uri("/UI/Pages/UserProfile.xaml?userId=" + usermodel.Id, UriKind.Relative));
 }
 private void ContactListOnTelegramUserSelected(object sender, UserModel user) {
     NavigationService.Navigate(new Uri("/UI/Pages/DialogPage.xaml?userId=" + user.Id, UriKind.Relative));
 }
        public void SaveUser(User user) {
                UserModel model = new UserModel(user);
                if (users.ContainsKey(model.Id)) {
                    Deployment.Current.Dispatcher.BeginInvoke(delegate {
                        users[model.Id].SetUser(user);
                    });
                }
                else {
                    users[model.Id] = model;
                }

        }
        private async void DoUnblock(UserModel model) {
            ShowProgress();
            bool result = await TelegramSession.Instance.Api.contacts_unblock(model.InputUser);
            
            if (result) {
                blockedUsers.Remove(model);
            } else {
                Toaster.ShowNetworkError();
            }

            HideProgress();
        }
 private void OnUserSelected(object sender, UserModel user) {
     DoSendContact(user);
     NavigationService.GoBack();
 }
 private void OnUserSelected(object sender, UserModel user) {
     Task.Run(() => TelegramSession.Instance.EncryptedChats.CreateChatRequest(user.InputUser));
     NavigationService.Navigate(new Uri("/UI/Pages/StartPage.xaml", UriKind.Relative));
 }