diff --git a/LivreLand/View/DetailsLivreView.xaml b/LivreLand/View/DetailsLivreView.xaml index 132be4e..386dba6 100644 --- a/LivreLand/View/DetailsLivreView.xaml +++ b/LivreLand/View/DetailsLivreView.xaml @@ -346,14 +346,12 @@ - - - - diff --git a/LivreLand/ViewModel/DetailsLivreVM.cs b/LivreLand/ViewModel/DetailsLivreVM.cs index 64ec30a..9bb2782 100644 --- a/LivreLand/ViewModel/DetailsLivreVM.cs +++ b/LivreLand/ViewModel/DetailsLivreVM.cs @@ -14,7 +14,7 @@ namespace LivreLand.ViewModel { #region Fields - private bool isPickerVisible; + private bool isPickerVisible = false; #endregion @@ -68,6 +68,7 @@ namespace LivreLand.ViewModel private void ShowPicker() { + Manager.GetAllStatusCommand.Execute(null); IsPickerVisible = true; } diff --git a/ViewModels/ManagerVM.cs b/ViewModels/ManagerVM.cs index b30e8dc..11f4c46 100644 --- a/ViewModels/ManagerVM.cs +++ b/ViewModels/ManagerVM.cs @@ -22,13 +22,15 @@ namespace ViewModels private readonly ObservableCollection pastLoans = new ObservableCollection(); private readonly ObservableCollection pastBorrowings = new ObservableCollection(); private readonly ObservableCollection currentBorrowings = new ObservableCollection(); - private readonly ObservableCollection contacts= new ObservableCollection(); + private readonly ObservableCollection contacts = new ObservableCollection(); + private readonly ObservableCollection status = new ObservableCollection(); private int index; private long nbBooks; private AuthorVM selectedAuthor; private PublishDateVM selectedDate; private RatingsVM selectedRating; + private Status selectedStatus; private ContactVM selectedContact; private string givenFirstName; @@ -92,6 +94,11 @@ namespace ViewModels get => contacts; } + public ObservableCollection AllStatus + { + get => status; + } + public BookVM SelectedBook { get; set; } public AuthorVM SelectedAuthor @@ -133,7 +140,18 @@ namespace ViewModels } } - public Status SelectedStatus { get; set; } + public Status SelectedStatus + { + get { return selectedStatus; } + set + { + if (selectedStatus != value) + { + selectedStatus = value; + OnPropertyChanged(nameof(SelectedStatus)); + } + } + } public ContactVM SelectedContact { @@ -224,6 +242,8 @@ namespace ViewModels public ICommand GetAllRatingsCommand { get; private set; } + public ICommand GetAllStatusCommand { get; private set; } + public ICommand GetToBeReadBooksCommand { get; private set; } public ICommand GetFavoriteBooksCommand { get; private set; } @@ -265,6 +285,7 @@ namespace ViewModels GetAllPublishDatesCommand = new RelayCommand(() => GetAllPublishDates()); GetBooksByRatingCommand = new RelayCommand(() => GetBooksByRating()); GetAllRatingsCommand = new RelayCommand(() => GetAllRatings()); + GetAllStatusCommand = new RelayCommand(() => GetAllStatus()); GetToBeReadBooksCommand = new RelayCommand(() => GetToBeReadBooks()); GetFavoriteBooksCommand = new RelayCommand(() => GetFavoriteBooks()); AddToFavoritesCommand = new RelayCommand(bookVM => AddToFavorites(bookVM)); @@ -470,6 +491,16 @@ namespace ViewModels OnPropertyChanged(nameof(AllRatings)); } + private async Task GetAllStatus() + { + var allStatusValues = Enum.GetValues(typeof(Status)).OfType(); + foreach (var s in allStatusValues) + { + status.Add(s); + } + OnPropertyChanged(nameof(AllStatus)); + } + private async Task GetToBeReadBooks() { var result = await Model.GetBooksFromCollection(0, 20);