diff --git a/LivreLand/View/DetailsLivreView.xaml b/LivreLand/View/DetailsLivreView.xaml
index 65ed64e..459bd3b 100644
--- a/LivreLand/View/DetailsLivreView.xaml
+++ b/LivreLand/View/DetailsLivreView.xaml
@@ -4,6 +4,7 @@
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:view="clr-namespace:LivreLand.View"
xmlns:contentView="clr-namespace:LivreLand.View.ContentViews"
+ xmlns:viewModel="clr-namespace:ViewModels;assembly=ViewModels"
x:Class="LivreLand.View.DetailsLivreView"
Title="DetailsLivreView">
@@ -112,9 +113,20 @@
-
+
+
+
+
+
+
+
+
+
+
@@ -125,18 +137,32 @@
-
+
+
+
+
+
-
+ Grid.Row="0"
+ Grid.Column="0"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -291,12 +317,15 @@
+ ButtonTitle="Ajouter à la liste À lire plus tard"
+ ButtonCommand="{Binding DetailsLivreVM.Manager.UpdateToBeReadBookCommand}"
+ ButtonCommandParameter="{Binding DetailsLivreVM.Book}"/>
+ ButtonTitle="Changer le statut de lecture"
+ ButtonCommand="{Binding DetailsLivreVM.Manager.UpdateStatusBookCommand}"/>
diff --git a/LivreLand/View/FiltrageAuteurView.xaml b/LivreLand/View/FiltrageAuteurView.xaml
index aa448e5..d52d985 100644
--- a/LivreLand/View/FiltrageAuteurView.xaml
+++ b/LivreLand/View/FiltrageAuteurView.xaml
@@ -38,8 +38,7 @@
+ SelectionChangedCommand="{Binding FiltrageAuteurVM.NavigateAuthorPageCommand}">
diff --git a/LivreLand/ViewModel/FiltrageAuteurVM.cs b/LivreLand/ViewModel/FiltrageAuteurVM.cs
index 59188a5..afa00b3 100644
--- a/LivreLand/ViewModel/FiltrageAuteurVM.cs
+++ b/LivreLand/ViewModel/FiltrageAuteurVM.cs
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Windows.Input;
using ViewModels;
namespace LivreLand.ViewModel
@@ -16,6 +17,8 @@ namespace LivreLand.ViewModel
public ManagerVM Manager { get; private set; }
+ public ICommand NavigateAuthorPageCommand { get; private set; }
+
#endregion
#region Constructor
@@ -24,6 +27,17 @@ namespace LivreLand.ViewModel
{
Navigator = navigatorVM;
Manager = managerVM;
+ NavigateAuthorPageCommand = new RelayCommand(() => NavigateAuthorPage());
+ }
+
+ #endregion
+
+ #region Methods
+
+ private async Task NavigateAuthorPage()
+ {
+ Manager.GetBooksByAuthorCommand.Execute(null);
+ Navigator.NavigationCommand.Execute("/tous");
}
#endregion
diff --git a/Model/Manager.cs b/Model/Manager.cs
index 8cbdbf7..69ac879 100644
--- a/Model/Manager.cs
+++ b/Model/Manager.cs
@@ -64,6 +64,11 @@ namespace Model
return UserLibraryManager.UpdateBook(book);
}
+ public Task RemoveBook(Book book)
+ {
+ return UserLibraryManager.RemoveBook(book);
+ }
+
public Task<(long count, IEnumerable books)> GetBooksFromCollection(int index, int count, string sort = "")
{
var result = UserLibraryManager.GetBooksFromCollection(index, count, sort).Result;
@@ -115,5 +120,10 @@ namespace Model
var result = UserLibraryManager.GetPastBorrowings(index, count).Result;
return Task.FromResult((result.Item1, result.Item2));
}
+
+ public Task LendBook(Book book, Contact contact, DateTime? loanDate)
+ {
+ return UserLibraryManager.LendBook(book, contact, loanDate);
+ }
}
}
diff --git a/ViewModels/ManagerVM.cs b/ViewModels/ManagerVM.cs
index 70ecc4a..a171132 100644
--- a/ViewModels/ManagerVM.cs
+++ b/ViewModels/ManagerVM.cs
@@ -84,6 +84,8 @@ namespace ViewModels
public RatingsVM SelectedRating { get; private set; }
+ public Status SelectedStatus { get; private set; }
+
public string SearchTitle { get; private set; }
public int Index
@@ -113,8 +115,16 @@ namespace ViewModels
public ICommand GetBooksFromCollectionCommand { get; private set; }
+ public ICommand UpdateBookCommand { get; private set; }
+
+ public ICommand UpdateStatusBookCommand { get; private set; }
+
+ public ICommand UpdateToBeReadBookCommand { get; private set; }
+
+ public ICommand RemoveBookCommand { get; private set; }
+
public ICommand GetBooksByAuthorCommand { get; private set; }
-
+
public ICommand GetAllAuthorsCommand { get; private set; }
public ICommand GetBooksByDateCommand { get; private set; }
@@ -129,6 +139,8 @@ namespace ViewModels
public ICommand AddToFavoritesCommand { get; private set; }
+ public ICommand RemoveFromFavoritesCommand { get; private set; }
+
public ICommand GetCurrentLoansCommand { get; private set; }
public ICommand GetPastLoansCommand { get; private set; }
@@ -148,6 +160,10 @@ namespace ViewModels
PreviousCommand = new RelayCommand(() => Previous());
NextCommand = new RelayCommand(() => Next());
GetBooksFromCollectionCommand = new RelayCommand(() => GetBooksFromCollection());
+ UpdateBookCommand = new RelayCommand((bookVM) => UpdateBook(bookVM));
+ UpdateStatusBookCommand = new RelayCommand((bookVM) => UpdateStatusBook(bookVM));
+ UpdateToBeReadBookCommand = new RelayCommand((bookVM) => UpdateToBeReadBook(bookVM));
+ RemoveBookCommand = new RelayCommand((bookVM) => RemoveBook(bookVM));
GetBooksByAuthorCommand = new RelayCommand(() => GetBooksByAuthor());
GetAllAuthorsCommand = new RelayCommand(() => GetAllAuthors());
GetBooksByDateCommand = new RelayCommand(() => GetBooksByDate());
@@ -157,6 +173,7 @@ namespace ViewModels
GetToBeReadBooksCommand = new RelayCommand(() => GetToBeReadBooks());
GetFavoriteBooksCommand = new RelayCommand(() => GetFavoriteBooks());
AddToFavoritesCommand = new RelayCommand(bookVM => AddToFavorites(bookVM));
+ RemoveFromFavoritesCommand = new RelayCommand(bookVM => RemoveFromFavorites(bookVM));
GetCurrentLoansCommand = new RelayCommand(() => GetCurrentLoans());
GetPastLoansCommand = new RelayCommand(() => GetPastLoans());
GetCurrentBorrowingsCommand = new RelayCommand(() => GetCurrentBorrowings());
@@ -202,6 +219,32 @@ namespace ViewModels
OnPropertyChanged(nameof(AllBooks));
}
+ private async Task UpdateBook(BookVM bookVM)
+ {
+ var book = await Model.GetBookById(bookVM.Id);
+ await Model.UpdateBook(book);
+ }
+
+ private async Task UpdateStatusBook(BookVM bookVM)
+ {
+ var book = await Model.GetBookById(bookVM.Id);
+ book.Status = SelectedStatus;
+ await Model.UpdateBook(book);
+ }
+
+ private async Task UpdateToBeReadBook(BookVM bookVM)
+ {
+ var book = await Model.GetBookById(bookVM.Id);
+ book.Status = Status.ToBeRead;
+ await Model.UpdateBook(book);
+ }
+
+ private async Task RemoveBook(BookVM bookVM)
+ {
+ var book = await Model.GetBookById(bookVM.Id);
+ await Model.RemoveBook(book);
+ }
+
private async Task GetBooksByAuthor()
{
var result = await Model.GetBooksByAuthor(SelectedAuthor.Name, Index, Count);
@@ -363,6 +406,13 @@ namespace ViewModels
await GetFavoriteBooks();
}
+ private async Task RemoveFromFavorites(BookVM bookVM)
+ {
+ var book = await Model.GetBookById(bookVM.Id);
+ await Model.RemoveFromFavorites(book.Id);
+ await GetFavoriteBooks();
+ }
+
private async Task GetCurrentLoans()
{
var result = await Model.GetCurrentLoans(0, 20);
@@ -411,6 +461,11 @@ namespace ViewModels
OnPropertyChanged(nameof(AllPastBorrowings));
}
+ //private async Task LendBook()
+ //{
+ // await Model.LendBook();
+ //}
+
#endregion
}
}
\ No newline at end of file