diff --git a/LivreLand/View/BibliothequeView.xaml b/LivreLand/View/BibliothequeView.xaml index ea22313..eaf0c42 100644 --- a/LivreLand/View/BibliothequeView.xaml +++ b/LivreLand/View/BibliothequeView.xaml @@ -55,8 +55,7 @@ ButtonNumber="{Binding BibliothequeVM.Manager.NbBooks}" ButtonRedIconVisible="False" ButtonBlackIconVisible="True" - ButtonTappedCommand="{Binding BibliothequeVM.Navigator.NavigationCommand}" - CommandParameter="tous/"/> + ButtonTappedCommand="{Binding BibliothequeVM.AllBooksNavigateCommand}"/> @@ -119,8 +118,7 @@ ButtonIcon="person_fill.png" ButtonRedIconVisible="False" ButtonBlackIconVisible="True" - ButtonTappedCommand="{Binding BibliothequeVM.Navigator.NavigationCommand}" - CommandParameter="auteur/"/> + ButtonTappedCommand="{Binding BibliothequeVM.AllAuthorsNavigateCommand}"/> @@ -129,8 +127,7 @@ ButtonIcon="calendar.png" ButtonRedIconVisible="False" ButtonBlackIconVisible="True" - ButtonTappedCommand="{Binding BibliothequeVM.Navigator.NavigationCommand}" - CommandParameter="date/"/> + ButtonTappedCommand="{Binding BibliothequeVM.AllDatesNavigateCommand}"/> @@ -139,8 +136,7 @@ ButtonIcon="sparkles.png" ButtonRedIconVisible="False" ButtonBlackIconVisible="True" - ButtonTappedCommand="{Binding BibliothequeVM.Navigator.NavigationCommand}" - CommandParameter="note/"/> + ButtonTappedCommand="{Binding BibliothequeVM.AllRatingsNavigateCommand}"/> diff --git a/LivreLand/View/FiltrageAuteurView.xaml.cs b/LivreLand/View/FiltrageAuteurView.xaml.cs index b6a5e10..52fb086 100644 --- a/LivreLand/View/FiltrageAuteurView.xaml.cs +++ b/LivreLand/View/FiltrageAuteurView.xaml.cs @@ -23,12 +23,5 @@ public partial class FiltrageAuteurView : ContentPage #region Methods - protected override void OnAppearing() - { - base.OnAppearing(); - - FiltrageAuteurVM.Manager.GetAllAuthorsCommand.Execute(null); - } - #endregion } \ No newline at end of file diff --git a/LivreLand/View/FiltrageDateView.xaml b/LivreLand/View/FiltrageDateView.xaml index 31c9615..878bb08 100644 --- a/LivreLand/View/FiltrageDateView.xaml +++ b/LivreLand/View/FiltrageDateView.xaml @@ -18,6 +18,7 @@ + SelectionChangedCommand="{Binding FiltrageDateVM.NavigateDatePageCommand}"> diff --git a/LivreLand/View/FiltrageDateView.xaml.cs b/LivreLand/View/FiltrageDateView.xaml.cs index 57694e9..729ed3d 100644 --- a/LivreLand/View/FiltrageDateView.xaml.cs +++ b/LivreLand/View/FiltrageDateView.xaml.cs @@ -23,12 +23,5 @@ public partial class FiltrageDateView : ContentPage #region Methods - protected override void OnAppearing() - { - base.OnAppearing(); - - FiltrageDateVM.Manager.GetAllPublishDatesCommand.Execute(null); - } - #endregion } \ No newline at end of file diff --git a/LivreLand/View/FiltrageNoteView.xaml b/LivreLand/View/FiltrageNoteView.xaml index 2c8eaac..2d19f6b 100644 --- a/LivreLand/View/FiltrageNoteView.xaml +++ b/LivreLand/View/FiltrageNoteView.xaml @@ -38,8 +38,8 @@ + SelectionMode="Single" + SelectionChangedCommand="{Binding FiltrageNoteVM.NavigateRatingPageCommand}"> diff --git a/LivreLand/View/FiltrageNoteView.xaml.cs b/LivreLand/View/FiltrageNoteView.xaml.cs index be91dfc..58fa2e8 100644 --- a/LivreLand/View/FiltrageNoteView.xaml.cs +++ b/LivreLand/View/FiltrageNoteView.xaml.cs @@ -23,12 +23,5 @@ public partial class FiltrageNoteView : ContentPage #region Methods - protected override void OnAppearing() - { - base.OnAppearing(); - - FiltrageNoteVM.Manager.GetAllRatingsCommand.Execute(null); - } - #endregion } \ No newline at end of file diff --git a/LivreLand/View/TousView.xaml.cs b/LivreLand/View/TousView.xaml.cs index c049510..8cfdfb8 100644 --- a/LivreLand/View/TousView.xaml.cs +++ b/LivreLand/View/TousView.xaml.cs @@ -35,12 +35,5 @@ public partial class TousView : ContentPage } } - protected override void OnAppearing() - { - base.OnAppearing(); - - TousVM.Manager.GetBooksFromCollectionCommand.Execute(null); - } - #endregion } \ No newline at end of file diff --git a/LivreLand/ViewModel/BibliothequeVM.cs b/LivreLand/ViewModel/BibliothequeVM.cs index 9b4b4ba..47fe84c 100644 --- a/LivreLand/ViewModel/BibliothequeVM.cs +++ b/LivreLand/ViewModel/BibliothequeVM.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,14 @@ namespace LivreLand.ViewModel public ManagerVM Manager { get; private set; } + public ICommand AllBooksNavigateCommand { get; private set; } + + public ICommand AllAuthorsNavigateCommand { get; private set; } + + public ICommand AllDatesNavigateCommand { get; private set; } + + public ICommand AllRatingsNavigateCommand { get; private set; } + #endregion #region Constructor @@ -24,6 +33,38 @@ namespace LivreLand.ViewModel { Navigator = navigatorVM; Manager = managerVM; + AllBooksNavigateCommand = new RelayCommand(() => AllBooksNavigate()); + AllAuthorsNavigateCommand = new RelayCommand(() => AllAuthorsNavigate()); + AllDatesNavigateCommand = new RelayCommand(() => AllDatesNavigate()); + AllRatingsNavigateCommand = new RelayCommand(() => AllRatingsNavigate()); + } + + #endregion + + #region Methods + + private void AllBooksNavigate() + { + Manager.GetBooksFromCollectionCommand.Execute(null); + Navigator.NavigationCommand.Execute("/tous"); + } + + private void AllAuthorsNavigate() + { + Manager.GetAllAuthorsCommand.Execute(null); + Navigator.NavigationCommand.Execute("/auteur"); + } + + private void AllDatesNavigate() + { + Manager.GetAllPublishDatesCommand.Execute(null); + Navigator.NavigationCommand.Execute("/date"); + } + + private void AllRatingsNavigate() + { + Manager.GetAllRatingsCommand.Execute(null); + Navigator.NavigationCommand.Execute("/note"); } #endregion diff --git a/LivreLand/ViewModel/FiltrageAuteurVM.cs b/LivreLand/ViewModel/FiltrageAuteurVM.cs index afa00b3..8927af6 100644 --- a/LivreLand/ViewModel/FiltrageAuteurVM.cs +++ b/LivreLand/ViewModel/FiltrageAuteurVM.cs @@ -34,7 +34,7 @@ namespace LivreLand.ViewModel #region Methods - private async Task NavigateAuthorPage() + private void NavigateAuthorPage() { Manager.GetBooksByAuthorCommand.Execute(null); Navigator.NavigationCommand.Execute("/tous"); diff --git a/LivreLand/ViewModel/FiltrageDateVM.cs b/LivreLand/ViewModel/FiltrageDateVM.cs index cdf7577..2ee0f3e 100644 --- a/LivreLand/ViewModel/FiltrageDateVM.cs +++ b/LivreLand/ViewModel/FiltrageDateVM.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 NavigateDatePageCommand { get; private set; } + #endregion #region Constructor @@ -24,6 +27,17 @@ namespace LivreLand.ViewModel { Navigator = navigatorVM; Manager = managerVM; + NavigateDatePageCommand = new RelayCommand(() => NavigateDatePage()); + } + + #endregion + + #region Methods + + private void NavigateDatePage() + { + Manager.GetBooksByDateCommand.Execute(null); + Navigator.NavigationCommand.Execute("/tous"); } #endregion diff --git a/LivreLand/ViewModel/FiltrageNoteVM.cs b/LivreLand/ViewModel/FiltrageNoteVM.cs index c262afa..d70f162 100644 --- a/LivreLand/ViewModel/FiltrageNoteVM.cs +++ b/LivreLand/ViewModel/FiltrageNoteVM.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 NavigateRatingPageCommand { get; private set; } + #endregion #region Constructor @@ -24,6 +27,17 @@ namespace LivreLand.ViewModel { Navigator = navigatorVM; Manager = managerVM; + NavigateRatingPageCommand = new RelayCommand(() => NavigateRatingPage()); + } + + #endregion + + #region Methods + + private void NavigateRatingPage() + { + Manager.GetBooksByRatingCommand.Execute(null); + Navigator.NavigationCommand.Execute("/tous"); } #endregion diff --git a/ViewModels/ManagerVM.cs b/ViewModels/ManagerVM.cs index 22ec2f5..b30e8dc 100644 --- a/ViewModels/ManagerVM.cs +++ b/ViewModels/ManagerVM.cs @@ -27,6 +27,8 @@ namespace ViewModels private long nbBooks; private AuthorVM selectedAuthor; + private PublishDateVM selectedDate; + private RatingsVM selectedRating; private ContactVM selectedContact; private string givenFirstName; @@ -105,9 +107,31 @@ namespace ViewModels } } - public PublishDateVM SelectedDate { get; private set; } + public PublishDateVM SelectedDate + { + get { return selectedDate; } + set + { + if (selectedDate != value) + { + selectedDate = value; + OnPropertyChanged(nameof(SelectedDate)); + } + } + } - public RatingsVM SelectedRating { get; private set; } + public RatingsVM SelectedRating + { + get { return selectedRating; } + set + { + if (selectedRating != value) + { + selectedRating = value; + OnPropertyChanged(nameof(SelectedRating)); + } + } + } public Status SelectedStatus { get; set; }