Beispiel #1
0
 public static AuthorCountViewModel ToViewModel(this AuthorCount obj)
 {
     return(new AuthorCountViewModel()
     {
         Author = obj.Author.ToViewModel(),
         Count = obj.Count,
         IsSearchingKey = obj.IsSearchingKey
     });
 }
Beispiel #2
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--;
         }
     }
 }
Beispiel #3
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));
         }
     }
 }