예제 #1
0
        private void Remove_Click(object sender, EventArgs e)
        {
            if (_model.Uid > 0)
            {
                var op = new FriendsDelete(_model.Uid, result =>
                {
                    App.Current.EntityService.DeleteFriend(_model.Uid);

                    NavigationService.Navigate(new Uri(@"/Views/FriendsPage.xaml", UriKind.Relative));
                });
                op.Execute();
            }
        }
        private void DeleteButton_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            var op = new FriendsDelete(_id,result =>
            {
                Dispatcher.BeginInvoke(() =>
                {
                    try
                    {
                        if (_isMutual)
                        {
                            var friend = App.Current.EntityService.FriendsMutual.FirstOrDefault(x => x.Uid == _id);

                            if (friend != null)
                                App.Current.EntityService.FriendsMutual.Remove(friend);
                        }
                        else
                        {
                            var friend = App.Current.EntityService.FriendsRequests.FirstOrDefault(x => x.Uid == _id);

                            if (friend != null)
                            {
                                App.Current.EntityService.FriendsRequests.Remove(friend);
                                App.Current.EntityService.StateCounter.CountOfRequests = App.Current.EntityService.FriendsRequests.Count;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine("DeleteButton_Tap failed: " + ex.Message);
                    }

                    NavigationService.Navigate(new Uri(@"/Views/FriendsPage.xaml", UriKind.Relative));
                });
            });
            op.Execute();
        }