diff --git a/LivreLand.sln b/LivreLand.sln
index 302c811..b4f2553 100644
--- a/LivreLand.sln
+++ b/LivreLand.sln
@@ -24,7 +24,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonReader", "JsonReader\Js
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Utils", "Utils\Utils.csproj", "{D74E6DD7-ED6A-400C-89EE-FA3BB50D924F}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PersonalMVVMToolkit", "PersonalMVVMToolkit\PersonalMVVMToolkit.csproj", "{DBB77CBE-CB7A-4277-B625-60DBD5749C12}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PersonalMVVMToolkit", "PersonalMVVMToolkit\PersonalMVVMToolkit.csproj", "{DBB77CBE-CB7A-4277-B625-60DBD5749C12}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{F2F8D537-7A2F-4B67-A7C6-F8B7FE37483D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -74,6 +76,10 @@ Global
{DBB77CBE-CB7A-4277-B625-60DBD5749C12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DBB77CBE-CB7A-4277-B625-60DBD5749C12}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DBB77CBE-CB7A-4277-B625-60DBD5749C12}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F2F8D537-7A2F-4B67-A7C6-F8B7FE37483D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F2F8D537-7A2F-4B67-A7C6-F8B7FE37483D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F2F8D537-7A2F-4B67-A7C6-F8B7FE37483D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F2F8D537-7A2F-4B67-A7C6-F8B7FE37483D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/LivreLand/View/TousView.xaml b/LivreLand/View/TousView.xaml
index 7defc8a..6f9f47d 100644
--- a/LivreLand/View/TousView.xaml
+++ b/LivreLand/View/TousView.xaml
@@ -8,9 +8,9 @@
x:Class="LivreLand.View.TousView"
Title="TousView">
-
+
+
+
@@ -24,8 +24,8 @@
HeaderPlusButtonVisible="True"
HeaderSwitchButtonVisible="True"
Grid.Row="0"
- ButtonPlusTappedCommand="{Binding Navigator.PopupHomePlusNavigationCommand}"
- ButtonBackTappedCommand="{Binding Navigator.PopupBackButtonNavigationCommand}"/>
+ ButtonPlusTappedCommand="{Binding TousVM.Navigator.PopupHomePlusNavigationCommand}"
+ ButtonBackTappedCommand="{Binding TousVM.Navigator.PopupBackButtonNavigationCommand}"/>
@@ -50,7 +50,7 @@
Style="{StaticResource HeaderCollectionViewText}"
Grid.Column="1"/>
-
diff --git a/LivreLand/View/TousView.xaml.cs b/LivreLand/View/TousView.xaml.cs
index 4d73f29..55f936d 100644
--- a/LivreLand/View/TousView.xaml.cs
+++ b/LivreLand/View/TousView.xaml.cs
@@ -9,6 +9,8 @@ public partial class TousView : ContentPage
#region Properties
+ public TousVM TousVM { get; set; }
+
public List DamasioBooks { get; set; } = new List()
{
new BookModel("La horde du contrevent","Alain Damasio","Non lu", 0),
@@ -28,6 +30,7 @@ public partial class TousView : ContentPage
public TousView(TousVM tousVM)
{
+ TousVM = tousVM;
InitializeComponent();
BindingContext = this;
}
diff --git a/PersonalMVVMToolkit/BaseViewModel.cs b/PersonalMVVMToolkit/BaseViewModel.cs
index 7c6aabc..7af6d40 100644
--- a/PersonalMVVMToolkit/BaseViewModel.cs
+++ b/PersonalMVVMToolkit/BaseViewModel.cs
@@ -35,10 +35,8 @@ namespace PersonalMVVMToolkit
Model = model;
}
- public BaseViewModel()
- {
- Model = default(TModel);
- }
+ public BaseViewModel() : this(default)
+ { }
#endregion
}
diff --git a/StubbedDTO/StubbedDTO.csproj b/StubbedDTO/StubbedDTO.csproj
index 64cfad4..e600184 100644
--- a/StubbedDTO/StubbedDTO.csproj
+++ b/StubbedDTO/StubbedDTO.csproj
@@ -1,22 +1,36 @@
-
- net7.0
- enable
- enable
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ net7.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Tests/Program.cs b/Tests/Program.cs
new file mode 100644
index 0000000..3fef173
--- /dev/null
+++ b/Tests/Program.cs
@@ -0,0 +1,99 @@
+using static System.Console;
+using Model;
+
+WriteLine("Test LibraryStub.GetBookByISBN");
+Stub.LibraryStub libStub = new Stub.LibraryStub();
+var book = await libStub.GetBookByISBN("9782330033118");
+WriteLine(book.Title);
+WriteLine(new string('*', WindowWidth));
+WriteLine();
+
+WriteLine("Test Manager.GetBookByISBN");
+Manager manager = new Manager(libStub, new Stub.UserLibraryStub(libStub));
+var book2 = await manager.GetBookByISBN("9782330033118");
+WriteLine(book2.Title);
+WriteLine(new string('*', WindowWidth));
+WriteLine();
+
+WriteLine("Test Manager.GetBooksByAuthor");
+var booksFromHerbert = await manager.GetBooksByAuthor("herbert", 0, 10);
+foreach (var b in booksFromHerbert.books)
+{
+ WriteLine($"\t{b.Title}");
+}
+WriteLine(new string('*', WindowWidth));
+WriteLine();
+
+WriteLine("Test Manager.GetBooks");
+var books = await manager.GetBooksByTitle("", 0, 100);
+foreach (var b in books.books)
+{
+ WriteLine($"\t{b.Title}");
+}
+WriteLine(new string('*', WindowWidth));
+WriteLine();
+
+WriteLine("Test Manager.AddBook");
+var book1 = await manager.AddBookToCollection("/books/OL25910297M");
+if (book1 == null) book1 = await manager.GetBookByIdFromCollection("/books/OL25910297M");
+book1.Status = Status.Finished;
+book1.UserRating = 5;
+book1.UserNote = "Trop bien !";
+manager.UpdateBook(book1);
+
+manager.AddBookToCollection("/books/OL26210208M");
+manager.AddBookToCollection("/books/OL27258011M");
+var mybooks = await manager.GetBooksFromCollection(0, 100);
+foreach (var b in mybooks.books)
+{
+ WriteLine($"\t{b.Title} {b.UserRating ?? -1}");
+}
+WriteLine(new string('*', WindowWidth));
+WriteLine();
+
+WriteLine("Test Manager.GetContacts");
+var contacts = await manager.GetContacts(0, 100);
+foreach (var c in contacts.contacts)
+{
+ WriteLine($"\t{c.FirstName} {c.LastName}");
+}
+WriteLine(new string('*', WindowWidth));
+WriteLine();
+
+WriteLine("Test Manager.GetCurrentLoans");
+var loans = await manager.GetCurrentLoans(0, 100);
+foreach (var l in loans.loans)
+{
+ WriteLine($"\t{l.Book.Title} -> {l.Loaner.FirstName} {l.Loaner.LastName} ({l.LoanedAt.ToShortDateString()})");
+}
+WriteLine(new string('*', WindowWidth));
+WriteLine();
+
+WriteLine("Test Manager.GetPastLoans");
+var loans2 = await manager.GetPastLoans(0, 100);
+foreach (var l in loans2.loans)
+{
+ WriteLine($"\t{l.Book.Title} -> {l.Loaner.FirstName} {l.Loaner.LastName} ({l.LoanedAt.ToShortDateString()})");
+}
+WriteLine(new string('*', WindowWidth));
+WriteLine();
+
+WriteLine("Test Manager.GetCurrentBorrowings");
+var borrowings = await manager.GetCurrentBorrowings(0, 100);
+foreach (var b in borrowings.borrowings)
+{
+ WriteLine($"\t{b.Book.Title} -> {b.Owner.FirstName} {b.Owner.LastName} ({b.BorrowedAt.ToShortDateString()})");
+}
+WriteLine(new string('*', WindowWidth));
+WriteLine();
+
+WriteLine("Test Manager.GetPastBorrowings");
+var borrowings2 = await manager.GetPastBorrowings(0, 100);
+foreach (var b in borrowings2.borrowings)
+{
+ WriteLine($"\t{b.Book.Title} -> {b.Owner.FirstName} {b.Owner.LastName} ({b.BorrowedAt.ToShortDateString()})");
+}
+WriteLine(new string('*', WindowWidth));
+WriteLine();
+
+ReadLine();
\ No newline at end of file
diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj
new file mode 100644
index 0000000..89f70e9
--- /dev/null
+++ b/Tests/Tests.csproj
@@ -0,0 +1,15 @@
+
+
+
+ Exe
+ net7.0
+ enable
+ enable
+
+
+
+
+
+
+
+
diff --git a/ViewModels/AuthorVM.cs b/ViewModels/AuthorVM.cs
new file mode 100644
index 0000000..8f6859d
--- /dev/null
+++ b/ViewModels/AuthorVM.cs
@@ -0,0 +1,40 @@
+using Model;
+using PersonalMVVMToolkit;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ViewModels
+{
+ public class AuthorVM : BaseViewModel
+ {
+
+ #region Fields
+
+ #endregion
+
+ #region Properties
+
+ public string Name
+ {
+ get => Model.Name;
+ set
+ {
+ Model.Name = value;
+ }
+ }
+
+ #endregion
+
+ #region Constructor
+
+ public AuthorVM(Author model) : base(model)
+ {
+
+ }
+
+ #endregion
+ }
+}
diff --git a/ViewModels/BookVM.cs b/ViewModels/BookVM.cs
index 7e1f88f..bcd831c 100644
--- a/ViewModels/BookVM.cs
+++ b/ViewModels/BookVM.cs
@@ -13,44 +13,71 @@ namespace ViewModels
#region Fields
- private Book model;
-
#endregion
#region Properties
- public Book Model
+ public string ISBN13
{
- get => model;
- set => model = value;
+ get => Model.ISBN13;
+ set => SetProperty(Model.ISBN13, value, v => Model.ISBN13 = value);
}
public string Title
{
- get => model.Title;
- set
- {
- model.Title = value;
- }
+ get => Model.Title;
+ set => SetProperty(Model.Title, value, v => Model.Title = value);
}
- //public float? UserRating
+ public List Publishers
+ {
+ get => Model.Publishers;
+ set => SetProperty(Model.Publishers, value, v => Model.Publishers = value);
+ }
+
+ public DateTime PublishDate
+ {
+ get => Model.PublishDate;
+ set => SetProperty(Model.PublishDate, value, v => Model.PublishDate = value);
+ }
+
+ //public List Authors
//{
- // get => Model?.UserRating;
+ // get => model.Authors;
// set
// {
- // if (Model == null) return;
- // SetProperty(Model.UserRating = value, rating => Model.UserRating);
+ // model.Authors = value;
// }
//}
+ public int NbPages
+ {
+ get => Model.NbPages;
+ set => SetProperty(Model.NbPages, value, v => Model.NbPages = value);
+ }
+
+ public string ImageSmall
+ {
+ get => Model.ImageSmall;
+ }
+
+ public float? UserRating
+ {
+ get => Model?.UserRating;
+ set
+ {
+ if (Model == null) return;
+ SetProperty(Model.UserRating, value, rating => Model.UserRating = rating);
+ }
+ }
+
#endregion
#region Constructor
- public BookVM(Book model)
+ public BookVM(Book b) : base(b)
{
- Model = model;
+
}
#endregion
diff --git a/ViewModels/ManagerVM.cs b/ViewModels/ManagerVM.cs
index 01ef16d..ba73047 100644
--- a/ViewModels/ManagerVM.cs
+++ b/ViewModels/ManagerVM.cs
@@ -10,22 +10,14 @@ namespace ViewModels
#region Fields
- private Manager model;
private readonly ObservableCollection books;
private int index;
private long nbBooks;
-
#endregion
#region Properties
- public Manager Model
- {
- get => model;
- private set => model = value;
- }
-
public ReadOnlyObservableCollection AllBooks { get; private set; }
public string SearchTitle { get; private set; }
@@ -49,6 +41,8 @@ namespace ViewModels
}
public int NbPages => (int)(NbBooks / Count);
+ public ICommand PreviousCommand { get; private set; }
+
public ICommand NextCommand { get; private set; }
public ICommand GetBooksByTitleCommand { get; private set; }
@@ -59,18 +53,39 @@ namespace ViewModels
#region Constructor
- public ManagerVM(Manager model)
+ public ManagerVM(Manager model) : base(model)
{
- Model = model;
- AllBooks = new ReadOnlyObservableCollection(books);
+ //AllBooks = new ReadOnlyObservableCollection(books);
+ PreviousCommand = new RelayCommand(() => Previous());
+ NextCommand = new RelayCommand(() => Next());
GetBooksFromCollectionCommand = new RelayCommand(() => GetBooksFromCollection());
//GetBooksByTitleCommand = new RelayCommand(() => AllBooks = model.GetBooksByTitle(SearchTitle, Index, Count).Result.books.Select(book => new BookVM(book)));
}
+ //public ManagerVM(ILibraryManager libMgr, IUserLibraryManager userLibMgr) : this (new Manager(libMgr, userLibMgr)) { }
+
#endregion
#region Methods
+ private async Task Previous()
+ {
+ if (Index > 0)
+ {
+ Index--;
+ await GetBooksFromCollection();
+ }
+ }
+
+ private async Task Next()
+ {
+ if (Index < NbPages)
+ {
+ Index++;
+ await GetBooksFromCollection();
+ }
+ }
+
private async Task GetBooksFromCollection()
{
var result = await Model.GetBooksFromCollection(Index, Count);