Exemplo n.º 1
0
 private void AuthorCountDecrement(NotifyCollectionChangedEventArgs e)
 {
     foreach (var removeBook in e.OldItems.Cast <BookViewModel>().Where(b => b.Author != null))
     {
         if (AuthorCount.Where(ac => ac.Author.Name == removeBook.Author.Name).Count() == 1)
         {
             var authorCount = AuthorCount.Single(ac => ac.Author.Name == removeBook.Author.Name);
             authorCount.Count--;
         }
     }
 }
Exemplo n.º 2
0
 private void AuthorCountInsertOrIncrement(NotifyCollectionChangedEventArgs e)
 {
     foreach (var newBook in e.NewItems.Cast <BookViewModel>().Where(b => b.Author != null))
     {
         if (AuthorCount.Where(ac => ac.Author.Name == newBook.Author.Name).Count() == 1)
         {
             var authorCount = AuthorCount.Single(ac => ac.Author.Name == newBook.Author.Name);
             authorCount.Count++;
         }
         else if (AuthorCount.Where(ac => ac.Author.Name == newBook.Author.Name).Count() == 0)
         {
             AuthorCount.Add(new AuthorCountViewModel(newBook.Author, 1));
         }
     }
 }