public void AddRemovedToFromAlbum(bool add, long targetId, long album_id, long owner_id, long video_id, Action <BackendResult <ResponseWithId, ResultCode> > callback) { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters["target_id"] = targetId.ToString(); parameters["album_id"] = album_id.ToString(); parameters["owner_id"] = owner_id.ToString(); parameters["video_id"] = video_id.ToString(); string methodName = add ? "video.addToAlbum" : "video.removeFromAlbum"; if (add && album_id == VideoAlbum.ADDED_ALBUM_ID) { methodName = "video.add"; } VKRequestsDispatcher.DispatchRequestToVK <ResponseWithId>(methodName, parameters, (Action <BackendResult <ResponseWithId, ResultCode> >)(res => { if (res.ResultCode == ResultCode.Succeeded) { EventAggregator current = EventAggregator.Current; VideoAddedDeleted videoAddedDeleted = new VideoAddedDeleted(); int num1 = add ? 1 : 0; videoAddedDeleted.IsAdded = num1 != 0; long num2 = video_id; videoAddedDeleted.VideoId = num2; long num3 = owner_id; videoAddedDeleted.OwnerId = num3; long num4 = targetId; videoAddedDeleted.TargetId = num4; long num5 = album_id; videoAddedDeleted.AlbumId = num5; current.Publish(videoAddedDeleted); } callback(res); }), (Func <string, ResponseWithId>)(jsonStr => new ResponseWithId()), false, true, new CancellationToken?(), null); }
public void Delete(long ownerId, long vid, Action <BackendResult <long, ResultCode> > callback) { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters["owner_id"] = ownerId.ToString(); parameters["video_id"] = vid.ToString(); VKRequestsDispatcher.DispatchRequestToVK <long>("video.delete", parameters, (Action <BackendResult <long, ResultCode> >)(res => { if (res.ResultCode == ResultCode.Succeeded) { EventAggregator current = EventAggregator.Current; VideoAddedDeleted videoAddedDeleted = new VideoAddedDeleted(); videoAddedDeleted.IsAdded = false; long num1 = vid; videoAddedDeleted.VideoId = num1; long num2 = ownerId; videoAddedDeleted.OwnerId = num2; int num3 = 1; videoAddedDeleted.IsDeletedPermanently = num3 != 0; current.Publish(videoAddedDeleted); } callback(res); }), null, false, true, new CancellationToken?(), null); }
public void Handle(VideoAddedDeleted message) { if (this.UserOrGroupId == AppGlobalStateManager.Current.LoggedInUserId && !this.IsGroup) { Execute.ExecuteOnUIThread((Action)(() => { if (message.IsAdded && message.AlbumId == VideoAlbum.ADDED_ALBUM_ID && (message.TargetId == 0L || message.TargetId == AppGlobalStateManager.Current.LoggedInUserId) && this._albumId == 0L) { this.AllVideosVM.LoadData(true, false, (Action <BackendResult <VKList <VKClient.Common.Backend.DataObjects.Video>, ResultCode> >)null, false); } else if (message.IsAdded && message.AlbumId == this._albumId && this._albumId != 0L && (message.TargetId == 0L || message.TargetId == AppGlobalStateManager.Current.LoggedInUserId)) { this.AllVideosVM.LoadData(true, false, (Action <BackendResult <VKList <VKClient.Common.Backend.DataObjects.Video>, ResultCode> >)null, false); } else { if ((message.IsAdded || message.IsDeletedPermanently || message.AlbumId != this._albumId) && (message.AlbumId != VideoAlbum.ADDED_ALBUM_ID || this._albumId != 0L)) { return; } VideoHeader videoHeader = this.AllVideosVM.Collection.FirstOrDefault <VideoHeader>((Func <VideoHeader, bool>)(v => { if (v.VKVideo.vid == message.VideoId) { return(v.VKVideo.owner_id == message.OwnerId); } return(false); })); if (videoHeader == null) { return; } this.AllVideosVM.Delete(videoHeader); } })); } if (!message.IsDeletedPermanently) { return; } Execute.ExecuteOnUIThread((Action)(() => { VideoHeader videoHeader1 = this.AllVideosVM.Collection.FirstOrDefault <VideoHeader>((Func <VideoHeader, bool>)(v => { if (v.VKVideo.vid == message.VideoId) { return(v.VKVideo.owner_id == message.OwnerId); } return(false); })); if (videoHeader1 != null) { this.AllVideosVM.Delete(videoHeader1); } VideoHeader videoHeader2 = this.UploadedVideosVM.Collection.FirstOrDefault <VideoHeader>((Func <VideoHeader, bool>)(v => { if (v.VKVideo.id == message.VideoId) { return(v.VKVideo.owner_id == message.OwnerId); } return(false); })); if (videoHeader2 == null) { return; } this.UploadedVideosVM.Delete(videoHeader2); })); }