Ejemplo n.º 1
0
 public void CheckFollowState()
 {
     if (GlobalVariables.UserOnline)
     {
         ViewModel.FollowButtonVisibility = true;
         var followStateRequest = new GetUserArtistRelationStoreRequest(ArtistID);
         followStateRequest.ProcessSuccessfully += (reply) =>
             Dispatcher.BeginInvoke((Action)delegate
             {
                 ViewModel.FollowState = (reply.user_relation.rel == UserRelationReply.Rel.FOLLOW);
             });
         followStateRequest.ProcessError += (reply, msg) =>
         {
             Debug.Assert(false, msg + reply.type);
             Dispatcher.BeginInvoke((Action)(() => StaticMainWindow.Window.ShowErrorScreen()));
         };
         GlobalVariables.StoreWorker.ForceAddRequest(followStateRequest);
     }
 }
Ejemplo n.º 2
0
        public object Process()
        {
            var relationRequest = new GetUserArtistRelationStoreRequest(ArtistID);
            var relationReply = (Reply)relationRequest.Process();
            if (relationReply.type != (decimal)Reply.Type.OK)
            {
                OnProcessError((Reply.Type)relationReply.type, "Get user-artist relationship failed");
                return null;
            }

            bool isFollow = (relationReply.user_relation.rel == UserRelationReply.Rel.FOLLOW);
            var followRequest = isFollow
                                    ? new FollowStoreRequest(FollowRequest.Type.UNFOLLOW, ArtistID)
                                    : new FollowStoreRequest(FollowRequest.Type.FOLLOW, ArtistID);
            var followReply = (Reply)followRequest.Process();
            if (followReply.type != (decimal)Reply.Type.OK)
            {
                OnProcessError((Reply.Type)followReply.type, "Follow artist request failed");
                return null;
            }
            OnProcessSuccessfully(isFollow);
            return null;
        }