Ajout par ISBN

master
Lucas EVARD 2 years ago
parent 5df7c6edb8
commit 163af17da5

@ -4,6 +4,7 @@ using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using MyToolkitMVVM;
using ViewModel;
namespace PocketBook.Applicative_VM
{
@ -11,6 +12,7 @@ namespace PocketBook.Applicative_VM
{
public ICommand ShowScanMenu { get; private set; }
public ICommand ModalISBN { get; private set; }
public ManagerVM Manager { get; private set; }
private bool scanMenuIsVisible;
@ -20,15 +22,19 @@ namespace PocketBook.Applicative_VM
set => SetProperty(ref scanMenuIsVisible,value);
}
public ScanMenuVM()
public ScanMenuVM(ManagerVM manager)
{
Manager = manager;
ShowScanMenu = new Command(() =>
{
ScanMenuIsVisible = !ScanMenuIsVisible;
});
ModalISBN = new Command(
async () => await App.Current.MainPage.DisplayPromptAsync("Ajout d'un livre par ISBN", "Entrez l'ISBN présent sur votre livre pour l'ajouter à votre librarie")
);
async () => {
string isbn = await App.Current.MainPage.DisplayPromptAsync("Ajout d'un livre par ISBN", "Entrez l'ISBN présent sur votre livre pour l'ajouter à votre librarie");
if (isbn != null) { Manager.AddBookByISBN(isbn); }
}
); ;
}
}
}

@ -83,8 +83,10 @@ public class ManagerVM : BaseViewModel<Manager>
{
OnPropertyChanged(nameof(GroupedBooks));
OnPropertyChanged(nameof(GroupedLaterBooks));
OnPropertyChanged(nameof(Books));
OnPropertyChanged(nameof(books));
//NbBookLater=books.Where(book => book.BookStatus == Status.ToBeRead).Count();
Debug.WriteLine(NbBookLater);
//Debug.WriteLine(NbBookLater);
}
public ManagerVM(Manager model) : base(model)
@ -93,6 +95,19 @@ public class ManagerVM : BaseViewModel<Manager>
Books = new ReadOnlyObservableCollection<BookVM>(books);
}
public void AddBookByISBN(string isbn)
{
var result= Model.GetBookByISBN(isbn).Result;
if (result != null) {
Debug.WriteLine(result.ToString());
//books.Add(new BookVM(result));
Model.AddBookToCollection(result.Id);
LoadBooksFromManager();
Refresh();
}
}
public int Index
{
get => index;

Loading…
Cancel
Save