ADD : Loan & Borrowing selection fonctionnel (ALirePlusTard Book Details ToDo)

commands-19-09
Lou BRODA 1 year ago
parent 456b275a84
commit 5c9c0e67fb

@ -16,6 +16,7 @@ public partial class AppShell : Shell
Routing.RegisterRoute("library/note/", typeof(FiltrageNoteView));
Routing.RegisterRoute("library/contacts/", typeof(ContactsView));
Routing.RegisterRoute("library/tous/details/", typeof(DetailsLivreView));
Routing.RegisterRoute("library/add/", typeof(AddBookView));
InitializeComponent();
}
}

@ -65,6 +65,9 @@
</ItemGroup>
<ItemGroup>
<MauiXaml Update="View\AddBookView.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="View\ALirePlusTardView.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>

@ -42,8 +42,10 @@
Grid.Column="1"/>
</Grid>
<CollectionView ItemsSource="{Binding ALirePlusTardVM.Manager.ToBeReadBooks}"
SelectedItem="{Binding ALirePlusTardVM.Manager.SelectedBook}"
SelectionMode="Single"
SelectionChanged="OnSelectionChanged"
SelectionChangedCommand="{Binding ALirePlusTardVM.OnSelectionChangedCommand}"
SelectionChangedCommandParameter="{Binding ALirePlusTardVM.Manager.SelectedBook}"
Grid.Row="2">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="viewModel:BookVM">

@ -24,11 +24,6 @@ public partial class ALirePlusTardView : ContentPage
#region Methods
void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
//App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView());
}
protected override void OnAppearing()
{
base.OnAppearing();

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="LivreLand.View.AddBookView"
Title="AddBookView">
<VerticalStackLayout>
<Label
Text="Welcome to .NET MAUI!"
VerticalOptions="Center"
HorizontalOptions="Center" />
</VerticalStackLayout>
</ContentPage>

@ -0,0 +1,9 @@
namespace LivreLand.View;
public partial class AddBookView : ContentPage
{
public AddBookView()
{
InitializeComponent();
}
}

@ -26,6 +26,10 @@
Margin="10,5,10,5">
<Label Text="Ajouter un livre"
Style="{StaticResource MasterStateBookText}"/>
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Navigator.NavigationCommand}"
CommandParameter="/add"/>
</Grid.GestureRecognizers>
</Grid>
<contentView:SeparatorEntireView Grid.Row="1"/>

@ -22,7 +22,7 @@
HeaderSwitchButtonVisible="False"
HeaderColor="{StaticResource HeaderGray}"
ButtonPlusTappedCommand="{Binding DetailsLivreVM.Navigator.PopupHomePlusNavigationCommand}"
ButtonBackTappedCommand="{Binding DetailsLivreVM.Navigator.PopupBackButtonNavigationCommand}"/>
ButtonBackTappedCommand="{Binding DetailsLivreVM.BackButtonCommand}"/>
<contentView:SeparatorEntireView/>
</VerticalStackLayout>
@ -140,31 +140,31 @@
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Label Text="Maison d'édition"
Style="{StaticResource DetailsLivreTitle}"
Grid.Row="0"/>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Label Text="Maison d'édition"
Style="{StaticResource DetailsLivreTitle}"
Grid.Row="0"
Grid.Column="0"/>
<Grid Grid.Row="1"
Grid.Column="1">
<CollectionView ItemsSource="{Binding DetailsLivreVM.Book.Publishers}">
<CollectionView ItemsSource="{Binding DetailsLivreVM.Book.Publishers}"
Grid.Column="0">
<CollectionView.ItemsLayout>
<LinearItemsLayout Orientation="Horizontal" />
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<Label Text="oui"
<Label Text="{Binding .}"
Style="{StaticResource DetailsLivreBody}"
Margin="0,0,5,0"
Grid.Row="1"/>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<Label Text="{Binding DetailsLivreVM.Book.PublishDate,StringFormat=' ({0:yyyy})'}"/>
<Label Text="{Binding DetailsLivreVM.Book.PublishDate,StringFormat=' ({0:yyyy})'}"
Grid.Column="1"/>
</Grid>
</Grid>
@ -223,7 +223,7 @@
<Label Text="Langue"
Style="{StaticResource DetailsLivreBody}"
Grid.Column="0"/>
<Label Text="français"
<Label Text="{Binding DetailsLivreVM.Book.Language}"
Style="{StaticResource DetailsLivreBody}"
Grid.Column="2"/>
</Grid>

@ -33,8 +33,10 @@
<ScrollView Grid.Row="4">
<Grid>
<CollectionView ItemsSource="{Binding EmpruntsPretsVM.Manager.AllCurrentLoans}"
SelectedItem="{Binding EmpruntsPretsVM.Manager.SelectedLoan}"
SelectionMode="Single"
SelectionChanged="OnSelectionChanged"
SelectionChangedCommand="{Binding EmpruntsPretsVM.OnSelectionLoanChangedCommand}"
SelectionChangedCommandParameter="{Binding EmpruntsPretsVM.Manager.SelectedBook}"
IsVisible="{Binding EmpruntsPretsVM.PretCollectionIsVisible}">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="viewModel:LoanVM">
@ -109,8 +111,10 @@
</CollectionView.ItemTemplate>
</CollectionView>
<CollectionView ItemsSource="{Binding EmpruntsPretsVM.Manager.AllCurrentBorrowings}"
SelectedItem="{Binding EmpruntsPretsVM.Manager.SelectedBorrowing}"
SelectionMode="Single"
SelectionChanged="OnSelectionChanged"
SelectionChangedCommand="{Binding EmpruntsPretsVM.OnSelectionBorrowingChangedCommand}"
SelectionChangedCommandParameter="{Binding EmpruntsPretsVM.Manager.SelectedBorrowing}"
IsVisible="{Binding EmpruntsPretsVM.EmpruntCollectionIsVisible}">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="viewModel:BorrowingVM">

@ -24,11 +24,6 @@ public partial class EmpruntsPretsView : ContentPage
#region Methods
void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
//App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView());
}
protected override void OnAppearing()
{
base.OnAppearing();

@ -27,8 +27,10 @@
<ScrollView Grid.Row="4">
<Grid>
<CollectionView ItemsSource="{Binding StatutLectureVM.Manager.AllBooks}"
SelectedItem="{Binding StatutLectureVM.Manager.SelectedBook}"
SelectionMode="Single"
SelectionChanged="OnSelectionChanged"
SelectionChangedCommand="{Binding StatutLectureVM.OnSelectionChangedCommand}"
SelectionChangedCommandParameter="{Binding StatutLectureVM.Manager.SelectedBook}"
Grid.Row="2">
<CollectionView.GroupHeaderTemplate>
<DataTemplate x:DataType="viewModel:BookVM">

@ -31,10 +31,5 @@ public partial class StatutLectureView : ContentPage
StatutLectureVM.Manager.GetBooksFromCollectionCommand.Execute(null);
}
void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
//App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView());
}
#endregion
}

@ -1,9 +1,11 @@
using PersonalMVVMToolkit;
using LivreLand.View;
using PersonalMVVMToolkit;
using System;
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 +18,8 @@ namespace LivreLand.ViewModel
public ManagerVM Manager { get; private set; }
public ICommand OnSelectionChangedCommand { get; private set; }
#endregion
#region Constructor
@ -24,6 +28,20 @@ namespace LivreLand.ViewModel
{
Navigator = navigatorVM;
Manager = managerVM;
OnSelectionChangedCommand = new RelayCommand<BookVM>((bookVM) => OnSelectionChanged(bookVM));
}
#endregion
#region Methods
private void OnSelectionChanged(BookVM bookVM)
{
if (bookVM != null)
{
var result = new DetailsLivreVM(Manager, Navigator, bookVM);
App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView(result));
}
}
#endregion

@ -65,6 +65,8 @@ namespace LivreLand.ViewModel
}
}
public ICommand BackButtonCommand { get; private set; }
public ICommand ShowPickerCommand { get; private set; }
public ICommand AddRemoveBookToFavoritesCommand { get; private set; }
@ -82,6 +84,7 @@ namespace LivreLand.ViewModel
Manager = managerVM;
Navigator = navigatorVM;
Book = bookVM;
BackButtonCommand = new RelayCommand(() => BackButton());
ShowPickerCommand = new RelayCommand(() => ShowPicker());
AddRemoveBookToFavoritesCommand = new RelayCommand<BookVM>((bookVM) => AddRemoveBookToFavorites(bookVM));
AddBookToReadListCommand = new RelayCommand<BookVM>((bookVM) => AddBookToReadList(bookVM));
@ -92,6 +95,11 @@ namespace LivreLand.ViewModel
#region Methods
private void BackButton()
{
Navigator.PopupBackButtonNavigationCommand.Execute(null);
}
private void ShowPicker()
{
Manager.GetAllStatusCommand.Execute(null);

@ -1,4 +1,6 @@
using PersonalMVVMToolkit;
using LivreLand.View;
using Model;
using PersonalMVVMToolkit;
using System;
using System.Collections.Generic;
using System.Linq;
@ -106,6 +108,10 @@ namespace LivreLand.ViewModel
}
}
public ICommand OnSelectionLoanChangedCommand { get; private set; }
public ICommand OnSelectionBorrowingChangedCommand { get; private set; }
public ICommand PretsButtonCommand { get; private set; }
public ICommand EmpruntsButtonCommand { get; private set; }
@ -118,6 +124,8 @@ namespace LivreLand.ViewModel
{
Navigator = navigatorVM;
Manager = managerVM;
OnSelectionLoanChangedCommand = new RelayCommand<LoanVM>((loanVM) => OnSelectionLoanChanged(loanVM));
OnSelectionBorrowingChangedCommand = new RelayCommand<BorrowingVM>((borrowingVM) => OnSelectionBorrowingChanged(borrowingVM));
PretsButtonCommand = new RelayCommand(() => PretsButtonClicked());
EmpruntsButtonCommand = new RelayCommand(() => EmpruntsButtonClicked());
}
@ -126,6 +134,38 @@ namespace LivreLand.ViewModel
#region Methods
private void OnSelectionLoanChanged(LoanVM loanVM)
{
if (loanVM == null)
{
foreach (var b in Manager.AllCurrentLoans)
{
if (b.Book.Id == loanVM.Book.Id)
{
var bookCorresponding = b.Book;
var result = new DetailsLivreVM(Manager, Navigator, bookCorresponding);
App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView(result));
}
}
}
}
private void OnSelectionBorrowingChanged(BorrowingVM borrowingVM)
{
if (borrowingVM != null)
{
foreach (var b in Manager.AllCurrentBorrowings)
{
if (b.Book.Id == borrowingVM.Book.Id)
{
var bookCorresponding = b.Book;
var result = new DetailsLivreVM(Manager, Navigator, bookCorresponding);
App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView(result));
}
}
}
}
public void PretsButtonClicked()
{
if (App.Current.PlatformAppTheme == AppTheme.Light)

@ -1,9 +1,11 @@
using PersonalMVVMToolkit;
using LivreLand.View;
using PersonalMVVMToolkit;
using System;
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 +18,8 @@ namespace LivreLand.ViewModel
public ManagerVM Manager { get; private set; }
public ICommand OnSelectionChangedCommand { get; private set; }
#endregion
#region Constructor
@ -24,6 +28,20 @@ namespace LivreLand.ViewModel
{
Navigator = navigatorVM;
Manager = managerVM;
OnSelectionChangedCommand = new RelayCommand<BookVM>((bookVM) => OnSelectionChanged(bookVM));
}
#endregion
#region Methods
private void OnSelectionChanged(BookVM bookVM)
{
if (bookVM != null)
{
var result = new DetailsLivreVM(Manager, Navigator, bookVM);
App.Current.MainPage.Navigation.PushAsync(new DetailsLivreView(result));
}
}
#endregion

@ -19,6 +19,7 @@ namespace LivreLand.ViewModel
public ManagerVM Manager { get; private set; }
public ICommand OnSelectionChangedCommand { get; private set; }
#endregion
#region Constructor

@ -64,6 +64,12 @@ namespace ViewModels
set => SetProperty(Model.NbPages, value, v => Model.NbPages = value);
}
public Languages Language
{
get => Model.Language;
set => SetProperty(Model.Language, value, v => Model.Language = value);
}
public string ImageSmall
{
get => Model.ImageSmall;

@ -33,6 +33,8 @@ namespace ViewModels
private RatingsVM selectedRating;
private Status selectedStatus;
private ContactVM selectedContact;
private LoanVM selectedLoan;
private BorrowingVM selectedBorrowing;
private string givenFirstName;
private string givenLastName;
@ -180,6 +182,32 @@ namespace ViewModels
}
}
public LoanVM SelectedLoan
{
get { return selectedLoan; }
set
{
if (selectedLoan != value)
{
selectedLoan = value;
OnPropertyChanged(nameof(SelectedLoan));
}
}
}
public BorrowingVM SelectedBorrowing
{
get { return selectedBorrowing; }
set
{
if (selectedBorrowing != value)
{
selectedBorrowing = value;
OnPropertyChanged(nameof(SelectedBorrowing));
}
}
}
public string GivenFirstName
{
get { return givenFirstName; }
@ -249,6 +277,8 @@ namespace ViewModels
public ICommand GetBooksFromCollectionCommand { get; private set; }
public ICommand AddBookCommand { get; private set; }
public ICommand UpdateBookCommand { get; private set; }
public ICommand UpdateStatusBookCommand { get; private set; }
@ -304,6 +334,7 @@ namespace ViewModels
PreviousCommand = new RelayCommand(() => Previous());
NextCommand = new RelayCommand(() => Next());
GetBooksFromCollectionCommand = new RelayCommand(() => GetBooksFromCollection());
AddBookCommand = new RelayCommand<BookVM>((bookVM) => AddBook(bookVM));
UpdateBookCommand = new RelayCommand<BookVM>((bookVM) => UpdateBook(bookVM));
UpdateStatusBookCommand = new RelayCommand<BookVM>((bookVM) => UpdateStatusBook(bookVM));
UpdateToBeReadBookCommand = new RelayCommand<BookVM>((bookVM) => UpdateToBeReadBook(bookVM));
@ -368,6 +399,12 @@ namespace ViewModels
OnPropertyChanged(nameof(AllBooks));
}
private async Task AddBook(BookVM bookVM)
{
await Model.AddBookToCollection(bookVM.Id);
GetBooksFromCollectionCommand.Execute(null);
}
private async Task UpdateBook(BookVM bookVM)
{
var book = await Model.GetBookById(bookVM.Id);

Loading…
Cancel
Save