public void Handle(DocumentEditedOrDeletedEvent message)
 {
     if (message.OwnerId != this._profileData.Id || message.IsEdited || message.NewDocumentsCount != 0)
     {
         return;
     }
     List <MediaListSectionViewModel> .Enumerator enumerator = this.Items.GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             MediaListSectionViewModel current = enumerator.Current;
             if (current.Title == CommonResources.Profile_Docs)
             {
                 if (!(current.ListItemViewModel is GenericMediaListItemViewModel))
                 {
                     break;
                 }
                 int index = this.Items.IndexOf(current);
                 this.Items.RemoveAt(index);
                 this.Items.Insert(index, this.GetDocumentsEmptyModel());
                 break;
             }
         }
     }
     finally
     {
         enumerator.Dispose();
     }
 }
Ejemplo n.º 2
0
        public void DeleteDocument(DocumentHeader item)
        {
            ObservableCollection <DocumentHeader> collection = this.CurrentSection.Items.Collection;
            DocumentHeader documentHeader = ((IEnumerable <DocumentHeader>)collection).FirstOrDefault <DocumentHeader>();

            if (documentHeader == item && collection.Count > 1)
            {
                documentHeader = collection[1];
            }
            if (documentHeader == null)
            {
                return;
            }
            DocumentEditedOrDeletedEvent editedOrDeletedEvent1 = new DocumentEditedOrDeletedEvent();

            editedOrDeletedEvent1.OwnerId    = item.Document.owner_id;
            editedOrDeletedEvent1.Id         = item.Document.id;
            editedOrDeletedEvent1.Title      = documentHeader.Name;
            editedOrDeletedEvent1.SizeString = documentHeader.GetSizeString();
            int num1 = 0;

            editedOrDeletedEvent1.IsEdited = num1 != 0;
            int num2 = this.CurrentSection.Items.TotalCount - 1;

            editedOrDeletedEvent1.NewDocumentsCount = num2;
            string str = string.Format("doc{0}_{1}", documentHeader.Document.owner_id, documentHeader.Document.id);

            editedOrDeletedEvent1.NewFirstDocumentId = str;
            DocumentEditedOrDeletedEvent editedOrDeletedEvent2 = editedOrDeletedEvent1;

            DocumentsService.Current.Delete(item.Document.owner_id, item.Document.id, (Action <BackendResult <VKClient.Audio.Base.ResponseWithId, ResultCode> >)(result => {}));
            EventAggregator.Current.Publish(editedOrDeletedEvent2);
        }
        public void Handle(DocumentEditedOrDeletedEvent message)
        {
            Execute.ExecuteOnUIThread(delegate
            {
                IEnumerable <DocumentHeader> arg_2F_0 = this.Items.Collection;
                Func <DocumentHeader, bool> arg_2F_1  = ((DocumentHeader i) => i.Document.owner_id == message.OwnerId && i.Document.id == message.Id);

                DocumentHeader documentHeader = Enumerable.FirstOrDefault <DocumentHeader>(arg_2F_0, arg_2F_1);
                if (documentHeader != null)
                {
                    if (message.IsEdited)
                    {
                        documentHeader.Name           = message.Title;
                        documentHeader.Document.title = message.Title;
                        return;
                    }
                    this.Items.Delete(documentHeader);
                }
            });
        }