ADD : Avancement modification Statut Lecture (bug selecteditem ToFix)

commands-19-09
Lou BRODA 1 year ago
parent ed0f18ae25
commit 47176188dd

@ -346,14 +346,12 @@
</VerticalStackLayout> </VerticalStackLayout>
<Picker SelectedItem="{Binding DetailsLivreVM.Manager.SelectedStatus}" <Picker ItemsSource="{Binding DetailsLivreVM.Manager.AllStatus}"
IsVisible="true" SelectedItem="{Binding DetailsLivreVM.Manager.SelectedStatus}"
IsVisible="{Binding DetailsLivreVM.IsPickerVisible}"
Grid.RowSpan="3" Grid.RowSpan="3"
HorizontalOptions="Center" HorizontalOptions="Center"
VerticalOptions="Center"> VerticalOptions="Center">
<Picker.ItemsSource>
<x:Array Type="{x:Type model:Status}"/>
</Picker.ItemsSource>
<Picker.Behaviors> <Picker.Behaviors>
<toolkit:EventToCommandBehavior Command="{Binding DetailsLivreVM.Manager.UpdateStatusBookCommand}" <toolkit:EventToCommandBehavior Command="{Binding DetailsLivreVM.Manager.UpdateStatusBookCommand}"
CommandParameter="{Binding DetailsLivreVM.Book}"/> CommandParameter="{Binding DetailsLivreVM.Book}"/>

@ -14,7 +14,7 @@ namespace LivreLand.ViewModel
{ {
#region Fields #region Fields
private bool isPickerVisible; private bool isPickerVisible = false;
#endregion #endregion
@ -68,6 +68,7 @@ namespace LivreLand.ViewModel
private void ShowPicker() private void ShowPicker()
{ {
Manager.GetAllStatusCommand.Execute(null);
IsPickerVisible = true; IsPickerVisible = true;
} }

@ -22,13 +22,15 @@ namespace ViewModels
private readonly ObservableCollection<LoanVM> pastLoans = new ObservableCollection<LoanVM>(); private readonly ObservableCollection<LoanVM> pastLoans = new ObservableCollection<LoanVM>();
private readonly ObservableCollection<BorrowingVM> pastBorrowings = new ObservableCollection<BorrowingVM>(); private readonly ObservableCollection<BorrowingVM> pastBorrowings = new ObservableCollection<BorrowingVM>();
private readonly ObservableCollection<BorrowingVM> currentBorrowings = new ObservableCollection<BorrowingVM>(); private readonly ObservableCollection<BorrowingVM> currentBorrowings = new ObservableCollection<BorrowingVM>();
private readonly ObservableCollection<ContactVM> contacts= new ObservableCollection<ContactVM>(); private readonly ObservableCollection<ContactVM> contacts = new ObservableCollection<ContactVM>();
private readonly ObservableCollection<Status> status = new ObservableCollection<Status>();
private int index; private int index;
private long nbBooks; private long nbBooks;
private AuthorVM selectedAuthor; private AuthorVM selectedAuthor;
private PublishDateVM selectedDate; private PublishDateVM selectedDate;
private RatingsVM selectedRating; private RatingsVM selectedRating;
private Status selectedStatus;
private ContactVM selectedContact; private ContactVM selectedContact;
private string givenFirstName; private string givenFirstName;
@ -92,6 +94,11 @@ namespace ViewModels
get => contacts; get => contacts;
} }
public ObservableCollection<Status> AllStatus
{
get => status;
}
public BookVM SelectedBook { get; set; } public BookVM SelectedBook { get; set; }
public AuthorVM SelectedAuthor 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 public ContactVM SelectedContact
{ {
@ -224,6 +242,8 @@ namespace ViewModels
public ICommand GetAllRatingsCommand { get; private set; } public ICommand GetAllRatingsCommand { get; private set; }
public ICommand GetAllStatusCommand { get; private set; }
public ICommand GetToBeReadBooksCommand { get; private set; } public ICommand GetToBeReadBooksCommand { get; private set; }
public ICommand GetFavoriteBooksCommand { get; private set; } public ICommand GetFavoriteBooksCommand { get; private set; }
@ -265,6 +285,7 @@ namespace ViewModels
GetAllPublishDatesCommand = new RelayCommand(() => GetAllPublishDates()); GetAllPublishDatesCommand = new RelayCommand(() => GetAllPublishDates());
GetBooksByRatingCommand = new RelayCommand(() => GetBooksByRating()); GetBooksByRatingCommand = new RelayCommand(() => GetBooksByRating());
GetAllRatingsCommand = new RelayCommand(() => GetAllRatings()); GetAllRatingsCommand = new RelayCommand(() => GetAllRatings());
GetAllStatusCommand = new RelayCommand(() => GetAllStatus());
GetToBeReadBooksCommand = new RelayCommand(() => GetToBeReadBooks()); GetToBeReadBooksCommand = new RelayCommand(() => GetToBeReadBooks());
GetFavoriteBooksCommand = new RelayCommand(() => GetFavoriteBooks()); GetFavoriteBooksCommand = new RelayCommand(() => GetFavoriteBooks());
AddToFavoritesCommand = new RelayCommand<BookVM>(bookVM => AddToFavorites(bookVM)); AddToFavoritesCommand = new RelayCommand<BookVM>(bookVM => AddToFavorites(bookVM));
@ -470,6 +491,16 @@ namespace ViewModels
OnPropertyChanged(nameof(AllRatings)); OnPropertyChanged(nameof(AllRatings));
} }
private async Task GetAllStatus()
{
var allStatusValues = Enum.GetValues(typeof(Status)).OfType<Status>();
foreach (var s in allStatusValues)
{
status.Add(s);
}
OnPropertyChanged(nameof(AllStatus));
}
private async Task GetToBeReadBooks() private async Task GetToBeReadBooks()
{ {
var result = await Model.GetBooksFromCollection(0, 20); var result = await Model.GetBooksFromCollection(0, 20);

Loading…
Cancel
Save