コード例 #1
0
 private void UpdateUserFriendStatus(long userId, int friendStatus)
 {
   SubscriptionItemHeader subscriptionItemHeader = this._searchVM.Collection.FirstOrDefault<SubscriptionItemHeader>((Func<SubscriptionItemHeader, bool>) (i => i.Id == userId));
   if (subscriptionItemHeader == null)
     return;
   subscriptionItemHeader.UpdateFriendStatus(friendStatus);
 }
コード例 #2
0
 public SubscriptionItemHeader(Group group)
     : this()
 {
     this._group = group;
     if (this._group == null)
     {
         return;
     }
     this.Id              = this._group.id;
     this.Title           = this._group.name;
     this.Subtitle        = SubscriptionItemHeader.GetSubtitle(this._group);
     this.ImageUrl        = this._group.photo_200;
     this._isVerified     = this._group.verified > 0;
     this._canSubscribe   = this._group.is_member == 0;
     this.TapAction       = (Action)(() => Navigator.Current.NavigateToGroup(this._group.id, this._group.name, false));
     this.SubscribeAction = (Action)(() =>
     {
         if (this._isInProgress)
         {
             return;
         }
         this.SetIsInProgress(false);
         GroupsService.Current.Join(this._group.id, false, (Action <BackendResult <OwnCounters, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() =>
         {
             if (result.ResultCode == ResultCode.Succeeded)
             {
                 this._group.is_member = 1;
                 this.UpdateGroupSubscriptionStatus();
             }
             this.SetIsInProgress(false);
         }))));
     });
     this.UnsubscribeAction = (Action)(() =>
     {
         if (this._isInProgress)
         {
             return;
         }
         this.SetIsInProgress(false);
         GroupsService.Current.Leave(this._group.id, (Action <BackendResult <OwnCounters, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() =>
         {
             if (result.ResultCode == ResultCode.Succeeded)
             {
                 this._group.is_member = 0;
                 this.UpdateGroupSubscriptionStatus();
             }
             this.SetIsInProgress(false);
         }))));
     });
 }
コード例 #3
0
 public SubscriptionItemHeader(User user, bool includeCommonFriendsInfo)
     : this()
 {
     this._user = user;
     if (this._user == null)
     {
         return;
     }
     this.Id              = this._user.id;
     this.Title           = this._user.Name;
     this.Subtitle        = SubscriptionItemHeader.GetSubtitle(this._user, includeCommonFriendsInfo);
     this.ImageUrl        = this._user.photo_max;
     this._isVerified     = this._user.verified > 0;
     this._canSubscribe   = this._user.friend_status == 0 || this._user.friend_status == 2;
     this.TapAction       = (Action)(() => Navigator.Current.NavigateToUserProfile(this._user.id, this._user.Name, "", false));
     this.SubscribeAction = (Action)(() =>
     {
         if (this._isInProgress)
         {
             return;
         }
         this.SetIsInProgress(true);
         UsersService.Instance.AddFriend(this._user.id, (Action <BackendResult <OwnCounters, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() =>
         {
             if (result.ResultCode == ResultCode.Succeeded)
             {
                 this.UpdateFriendStatus(1);
             }
             this.SetIsInProgress(false);
         }))));
     });
     this.UnsubscribeAction = (Action)(() =>
     {
         if (this._isInProgress)
         {
             return;
         }
         this.SetIsInProgress(true);
         UsersService.Instance.DeleteFriend(this._user.id, (Action <BackendResult <OwnCounters, ResultCode> >)(result => Execute.ExecuteOnUIThread((Action)(() =>
         {
             if (result.ResultCode == ResultCode.Succeeded)
             {
                 this.UpdateFriendStatus(0);
             }
             this.SetIsInProgress(false);
         }))));
     });
 }