FIX : some using of MyToolkit & Debug .csproj

commands-19-09
Lou BRODA 1 year ago
parent 65f7d93a78
commit 7a2ae56ca8

@ -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

@ -8,9 +8,9 @@
x:Class="LivreLand.View.TousView"
Title="TousView">
<!--<ContentPage.Behaviors>
<toolkit:EventToCommandBehavior />
</ContentPage.Behaviors>-->
<ContentPage.Behaviors>
<toolkit:EventToCommandBehavior Command="{Binding TousVM.Manager.GetBooksFromCollectionCommand}"/>
</ContentPage.Behaviors>
<Grid>
<Grid.RowDefinitions>
@ -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}"/>
<ScrollView Grid.Row="2">
<Grid>
<Grid.RowDefinitions>
@ -50,7 +50,7 @@
Style="{StaticResource HeaderCollectionViewText}"
Grid.Column="1"/>
</Grid>
<CollectionView ItemsSource="{Binding Manager.AllBooks}"
<CollectionView ItemsSource="{Binding TousVM.Manager.AllBooks}"
SelectionMode="Single"
Grid.Row="2">
<CollectionView.ItemTemplate>

@ -9,6 +9,8 @@ public partial class TousView : ContentPage
#region Properties
public TousVM TousVM { get; set; }
public List<BookModel> DamasioBooks { get; set; } = new List<BookModel>()
{
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;
}

@ -35,10 +35,8 @@ namespace PersonalMVVMToolkit
Model = model;
}
public BaseViewModel()
{
Model = default(TModel);
}
public BaseViewModel() : this(default)
{ }
#endregion
}

@ -1,22 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DtoAbstractLayer\DtoAbstractLayer.csproj" />
<ProjectReference Include="..\JsonReader\JsonReader.csproj" />
<ProjectReference Include="..\LibraryDTO\LibraryDTO.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="authors\" />
<Folder Include="books\" />
<Folder Include="works\" />
<Folder Include="ratings\" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<!--<ItemGroup>
<None Remove="books\" />
<None Remove="authors\" />
<None Remove="works\" />
<None Remove="ratings\" />
<None Remove="authors\OL13066A.json" />
</ItemGroup>-->
<ItemGroup>
<Folder Include="books\" />
<Folder Include="authors\" />
<Folder Include="works\" />
<Folder Include="ratings\" />
</ItemGroup>
<!--<ItemGroup>
<None Include="*\*.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>-->
<ItemGroup>
<ProjectReference Include="..\DtoAbstractLayer\DtoAbstractLayer.csproj" />
<ProjectReference Include="..\JsonReader\JsonReader.csproj" />
<ProjectReference Include="..\LibraryDTO\LibraryDTO.csproj" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="*\*.json" />
</ItemGroup>
</Project>

@ -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();

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
<ProjectReference Include="..\Stub\Stub.csproj" />
</ItemGroup>
</Project>

@ -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<Author>
{
#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
}
}

@ -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<string> 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<AuthorVM> 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

@ -10,22 +10,14 @@ namespace ViewModels
#region Fields
private Manager model;
private readonly ObservableCollection<BookVM> books;
private int index;
private long nbBooks;
#endregion
#region Properties
public Manager Model
{
get => model;
private set => model = value;
}
public ReadOnlyObservableCollection<BookVM> 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<BookVM>(books);
//AllBooks = new ReadOnlyObservableCollection<BookVM>(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);

Loading…
Cancel
Save