|
|
|
@ -1,32 +1,88 @@
|
|
|
|
|
using Model;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
|
|
|
|
|
namespace VMWrapper
|
|
|
|
|
{
|
|
|
|
|
// All the code in this file is included in all platforms.
|
|
|
|
|
public class BookViewModel
|
|
|
|
|
public class BookViewModel : INotifyPropertyChanged
|
|
|
|
|
{
|
|
|
|
|
ILibraryManager data;
|
|
|
|
|
|
|
|
|
|
ObservableCollection<Author> authorList;
|
|
|
|
|
|
|
|
|
|
public BookViewModel(ILibraryManager data)
|
|
|
|
|
public ObservableCollection<Author> authorList { get; private set; } = new ObservableCollection<Author>();
|
|
|
|
|
public ObservableCollection<Book> bookList { get; private set; } = new ObservableCollection<Book>();
|
|
|
|
|
public ObservableCollection<AuteurGroup> AuteurGroups { get; private set; } = new ObservableCollection<AuteurGroup>();
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
|
|
|
|
|
public BookViewModel(ILibraryManager data)
|
|
|
|
|
{
|
|
|
|
|
this.data = data;
|
|
|
|
|
GetAuthors();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
|
|
|
|
{
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class AuteurGroup : ObservableCollection<Book>
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; private set; }
|
|
|
|
|
|
|
|
|
|
public AuteurGroup(string name, ObservableCollection<Book> books): base(books)
|
|
|
|
|
{
|
|
|
|
|
Name = name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void GetBooks()
|
|
|
|
|
{
|
|
|
|
|
var objet = data.GetBooksByAuthor("", 0, 8);
|
|
|
|
|
var ojb = objet.Result.Item2;
|
|
|
|
|
|
|
|
|
|
/*foreach (Book Book in ojb)
|
|
|
|
|
{
|
|
|
|
|
AuteurGroups.Add(new AuteurGroup(Book.Authors.Name, auteur.Books));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ObservableCollection<Auteur> auteurs = new Stub().CreateStubData();
|
|
|
|
|
foreach (Auteur auteur in auteurs)
|
|
|
|
|
{
|
|
|
|
|
AuteurGroups.Add(new AuteurGroup(auteur.Name, auteur.Books));
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<ObservableCollection<Author>> GetAuthor()
|
|
|
|
|
|
|
|
|
|
public void GetAuthors()
|
|
|
|
|
{
|
|
|
|
|
var objet = await data.GetAuthorsByName("",0,10);
|
|
|
|
|
var objet = data.GetAuthorsByName("",0,10);
|
|
|
|
|
var ojb = objet.Result.Item2;
|
|
|
|
|
|
|
|
|
|
authorList.Clear();
|
|
|
|
|
foreach (var author in ojb)
|
|
|
|
|
{
|
|
|
|
|
authorList.Add(author);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<ObservableCollection<Book>> GetBooksByTitle()
|
|
|
|
|
{
|
|
|
|
|
var objet = await data.GetBooksByTitle("", 0, 9);
|
|
|
|
|
var ojb = objet.Item2;
|
|
|
|
|
|
|
|
|
|
return new ObservableCollection<Author>(ojb);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new ObservableCollection<Book>(ojb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|