Add(Back-End): Suppresion d'un livre ok
continuous-integration/drone/push Build is failing Details

Back-End
Louis DUFOUR 2 years ago
parent d058835cd6
commit 2469160920

@ -13,7 +13,7 @@
</ResourceDictionary>
</ContentView.Resources>
<CollectionView ItemsSource="{Binding AuteurGroups}" IsGrouped="True" SelectionMode="Single">
<CollectionView ItemsSource="{Binding AuteurGroups}" IsGrouped="True" SelectionMode="Single" x:Name="groupCollectionView">
<CollectionView.GroupHeaderTemplate>
<DataTemplate x:DataType="model:Author">
<Label Text="{Binding Name}"
@ -29,11 +29,13 @@
<SwipeView.LeftItems>
<SwipeItems>
<SwipeItem Text="Favorite"
IconImageSource="favorite.png"
BackgroundColor="LightGreen"/>
IconImageSource="favorite.png"
BackgroundColor="LightGreen"/>
<SwipeItem Text="Delete"
IconImageSource="delete.png"
BackgroundColor="LightPink"/>
IconImageSource="delete.png"
BackgroundColor="LightPink"
Command="{Binding Source={x:Reference groupCollectionView}, Path=BindingContext.RemoveBookCommand}"
CommandParameter="{Binding Id}"/>
</SwipeItems>
</SwipeView.LeftItems>
<StackLayout>

@ -22,7 +22,7 @@
<Label
x:Name="OffLabel"
Text="Prêts"
Opacity="0.5"
Opacity="0.25"
VerticalTextAlignment="Center"/>
<Grid
@ -39,7 +39,7 @@
<Label
x:Name="OnLabel"
Text="Emprunts"
Opacity="0.5"
Opacity="0.25"
VerticalTextAlignment="Center"/>
</StackLayout>

@ -13,11 +13,11 @@ public partial class ToggleSwitchView : ContentView
if (e.Value) // Si c'est ON
{
OnLabel.Opacity = 1;
OffLabel.Opacity = 0.5;
OffLabel.Opacity = 0.25;
}
else // Si c'est OFF
{
OnLabel.Opacity = 0.5;
OnLabel.Opacity = 0.25;
OffLabel.Opacity = 1;
}
}

@ -48,7 +48,7 @@
<Grid RowDefinitions="Auto" Style="{StaticResource StyleCollectionGrid}" Padding="2">
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={x:Reference ThisPage}, Path=Nav.MenuItemsCommand}"
CommandParameter="{Binding .}"/>
CommandParameter="{Binding .}" NumberOfTapsRequired="1"/>
</Grid.GestureRecognizers>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25"/>
@ -104,7 +104,7 @@
<Grid RowDefinitions="Auto" Style="{StaticResource StyleCollectionGrid}" Padding="2">
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={x:Reference ThisPage}, Path=Nav.MenuItemsFiltreCommand}"
CommandParameter="{Binding .}"/>
CommandParameter="{Binding .}" NumberOfTapsRequired="1"/>
</Grid.GestureRecognizers>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25" />

@ -29,6 +29,7 @@ namespace BookApp
builder.Logging.AddDebug();
#endif
builder.Services.AddSingleton<ILibraryManager, LibraryStub>();
builder.Services.AddSingleton<IUserLibraryManager, UserLibraryStub>();
builder.Services.AddSingleton<BooksViewModel>();
builder.Services.AddSingleton<FilterViewModel>();
builder.Services.AddSingleton<SearchBarViewModel>();

@ -23,7 +23,7 @@
HorizontalOptions="Start">
<Image.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding Source={x:Reference ThisPage}, Path=Nav.BackButtonCommand}"/>
Command="{Binding Source={x:Reference ThisPage}, Path=Nav.BackButtonCommand}" NumberOfTapsRequired="1"/>
</Image.GestureRecognizers>
<Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="Red" />
@ -51,11 +51,11 @@
</Grid>
</Shell.TitleView>
<ContentView.Resources>
<ContentPage.Resources>
<ResourceDictionary>
<usecase:AuthorsListToStringConverter x:Key="authorsConverter"/>
</ResourceDictionary>
</ContentView.Resources>
</ContentPage.Resources>
<ContentPage.Content>
<ScrollView>
@ -175,6 +175,9 @@
<ColumnDefinition Width="25"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding PopUpCommand}" NumberOfTapsRequired="1"/>
</Grid.GestureRecognizers>
<Image Grid.Column="0" HeightRequest="25"
WidthRequest="25" Source="eyeglasses.svg">
<Image.Behaviors>

@ -21,7 +21,7 @@
HorizontalOptions="Start">
<Image.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding Source={x:Reference ThisPage}, Path=Nav.BackButtonCommand}"/>
Command="{Binding Source={x:Reference ThisPage}, Path=Nav.BackButtonCommand}" NumberOfTapsRequired="1"/>
</Image.GestureRecognizers>
<Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="Red" />
@ -70,8 +70,17 @@
</HorizontalStackLayout>
</Grid>
</Shell.TitleView>
<StackLayout>
<composants:ToggleSwitchView VerticalOptions="Center" HorizontalOptions="Center" />
<composants:GroupCollection/>
</StackLayout>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Rectangle HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="Start" />
<composants:ToggleSwitchView Grid.Row="0" VerticalOptions="Center" HorizontalOptions="Center"/>
<Rectangle HeightRequest="1" BackgroundColor="LightGray" VerticalOptions="End" />
<ScrollView Grid.Row="1">
<composants:GroupCollection/>
</ScrollView>
</Grid>
</ContentPage>

@ -22,7 +22,7 @@
HorizontalOptions="Start">
<Image.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding Source={x:Reference ThisPage}, Path=Nav.BackButtonCommand}"/>
Command="{Binding Source={x:Reference ThisPage}, Path=Nav.BackButtonCommand}" NumberOfTapsRequired="1"/>
</Image.GestureRecognizers>
<Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="Red" />

@ -22,7 +22,7 @@
HorizontalOptions="Start">
<Image.GestureRecognizers>
<TapGestureRecognizer
Command="{Binding Source={x:Reference ThisPage}, Path=Nav.BackButtonCommand}"/>
Command="{Binding Source={x:Reference ThisPage}, Path=Nav.BackButtonCommand}" NumberOfTapsRequired="1"/>
</Image.GestureRecognizers>
<Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="Red" />

@ -1,6 +1,7 @@
using Model;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Windows.Input;
using ToolKit;
using VMWrapper;
@ -37,11 +38,57 @@ namespace BookApp.ViewModel
}
}
// Command Pop-up
public ICommand _popUpCommand;
public ICommand PopUpCommand =>
_popUpCommand ??= new CommandPersonnal(ShowPopUP);
public ViewModelDetailProvider(DetailBookViewModel detailBookViewModel)
{
_detailBookViewModel =
detailBookViewModel ?? throw new ArgumentNullException(nameof(detailBookViewModel));
}
private async void ShowPopUP()
{
string action = await DisplayActionSheet("Quel est le statut du livre ?", "Cancel", null, "Finished", "Reading", "NotRead", "ToBeRead");
switch (action)
{
case "Finished":
BookDetail.Status = Status.Finished;
OnPropertyChanged(nameof(BookDetail));
_detailBookViewModel.UpdateColleciton();
break;
case "Reading":
BookDetail.Status = Status.Reading;
OnPropertyChanged(nameof(BookDetail));
_detailBookViewModel.UpdateColleciton();
break;
case "NotRead":
BookDetail.Status = Status.NotRead;
OnPropertyChanged(nameof(BookDetail));
_detailBookViewModel.UpdateColleciton();
break;
case "ToBeRead":
BookDetail.Status = Status.ToBeRead;
OnPropertyChanged(nameof(BookDetail));
_detailBookViewModel.UpdateColleciton();
break;
default:
BookDetail.Status = Status.Unknown;
OnPropertyChanged(nameof(BookDetail));
break;
}
}
public async Task<string> DisplayActionSheet(string title, string cancel, string destruction, params string[] buttons)
{
return await Application.Current.MainPage.DisplayActionSheet(title, cancel, destruction, buttons);
}
private async void LoadBookDetailAsync(string bookId)
{

@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using VMWrapper;
namespace BookApp.ViewModel
{
@ -7,39 +8,39 @@ namespace BookApp.ViewModel
public ObservableCollection<ViewModelMenuItem> MenuItemsLivre { get; set; }
public ObservableCollection<ViewModelMenuItem> MenuItemsFiltre { get; set; }
public ViewModelMenu()
public ViewModelMenu(BooksViewModel booksViewModel)
{
MenuItemsLivre = new ObservableCollection<ViewModelMenuItem>()
{
new ViewModelMenuItem(
"Tous",
"../Resources/Images/tray_2_fill.svg",
250,
booksViewModel.TotalBooks,
"TousPage"
),
new ViewModelMenuItem(
"En prêt",
"../Resources/Images/person_badge_clock_fill.svg",
250,
null,
"EmpruntsPretsPage"
),
new ViewModelMenuItem(
"À lire plus tard",
"../Resources/Images/arrow_forward.svg",
250,
null,
""
),
new ViewModelMenuItem(
"Statut de lecture",
"../Resources/Images/eyeglasses.svg",
250,
null,
""
),
new ViewModelMenuItem("Favoris", "../Resources/Images/heart_fill.svg", 250, ""),
new ViewModelMenuItem("Favoris", "../Resources/Images/heart_fill.svg", null, ""),
new ViewModelMenuItem(
"Étiquettes",
"../Resources/Images/tag_fill.svg",
250,
null,
"",
true
),
@ -50,16 +51,16 @@ namespace BookApp.ViewModel
new ViewModelMenuItem(
"Auteur",
"../Resources/Images/person_fill.svg",
250,
booksViewModel.TotalAuthors,
"FiltragePage"
),
new ViewModelMenuItem(
"Date de publication",
"../Resources/Images/calendar.svg",
250,
null,
"FiltragePage"
),
new ViewModelMenuItem("Note", "../Resources/Images/sparkles.svg", 250, "", true),
new ViewModelMenuItem("Note", "../Resources/Images/sparkles.svg", null, "", true),
};
}
}

@ -10,14 +10,14 @@ namespace BookApp.ViewModel
{
public string Name { get; set; }
public string Icone { get; set; }
public int Number { get; set; }
public long? Number { get; set; }
public string Route { get; set; }
public bool IsLastItem { get; set; }
public ViewModelMenuItem(
string name,
string icone,
int number,
long? number,
string route,
bool isLastItem = false
)

@ -4,6 +4,7 @@ using Model;
using System.Linq;
using LibraryDTO;
using System.Xml.Linq;
using System.Diagnostics;
namespace StubLib
{

@ -0,0 +1,239 @@
using Model;
using System.Collections.ObjectModel;
namespace ToolKit
{
public class ObservableBook : BaseViewModel
{
private Book _book;
public Book Book
{
get { return _book; }
set
{
if (_book != value)
{
_book = value;
OnPropertyChanged(nameof(Book));
}
}
}
public ObservableBook(Book book)
{
_book = book;
}
public string Id
{
get => _book.Id;
set
{
if (_book.Id != value)
{
_book.Id = value;
OnPropertyChanged();
}
}
}
public string Title
{
get => _book.Title;
set
{
if (_book.Title != value)
{
_book.Title = value;
OnPropertyChanged();
}
}
}
public DateTime PublishDate
{
get => _book.PublishDate;
set
{
if (_book.PublishDate != value)
{
_book.PublishDate = value;
OnPropertyChanged();
}
}
}
public List<string> Publishers
{
get => _book.Publishers;
set
{
if (_book.Publishers != value)
{
_book.Publishers = value;
OnPropertyChanged();
}
}
}
public string ISBN13
{
get => _book.ISBN13;
set
{
if (_book.ISBN13 != value)
{
_book.ISBN13 = value;
OnPropertyChanged();
}
}
}
public List<string> Series
{
get => _book.Series;
set
{
if (_book.Series != value)
{
_book.Series = value;
OnPropertyChanged();
}
}
}
public int NbPages
{
get => _book.NbPages;
set
{
if (_book.NbPages != value)
{
_book.NbPages = value;
OnPropertyChanged();
}
}
}
public string Format
{
get => _book.Format;
set
{
if (_book.Format != value)
{
_book.Format = value;
OnPropertyChanged();
}
}
}
public Languages Language
{
get => _book.Language;
set
{
if (_book.Language != value)
{
_book.Language = value;
OnPropertyChanged();
}
}
}
public List<Contributor> Contributors
{
get => _book.Contributors;
set
{
if (_book.Contributors != value)
{
_book.Contributors = value;
OnPropertyChanged();
}
}
}
public string ImageSmall => _book.ImageSmall;
public string ImageMedium => _book.ImageMedium;
public string ImageLarge => _book.ImageLarge;
public List<Work> Works
{
get => _book.Works;
set
{
if (_book.Works != value)
{
_book.Works = value;
OnPropertyChanged();
}
}
}
public List<Author> Authors
{
get => _book.Authors;
set
{
if (_book.Authors != value)
{
_book.Authors = value;
OnPropertyChanged();
}
}
}
public Status Status
{
get => _book.Status;
set
{
if (_book.Status != value)
{
_book.Status = value;
OnPropertyChanged();
}
}
}
public List<string> UserTags
{
get => _book.UserTags;
set
{
if (_book.UserTags != value)
{
_book.UserTags = value;
OnPropertyChanged();
}
}
}
public float? UserRating
{
get => _book.UserRating;
set
{
if (_book.UserRating != value)
{
_book.UserRating = value;
OnPropertyChanged();
}
}
}
public string UserNote
{
get => _book.UserNote;
set
{
if (_book.UserNote != value)
{
_book.UserNote = value;
OnPropertyChanged();
}
}
}
}
}

@ -6,4 +6,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project>

@ -1,37 +1,75 @@
using Model;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows.Input;
using ToolKit;
namespace VMWrapper
{
public class BooksViewModel
public class BooksViewModel: BaseViewModel
{
private readonly ILibraryManager data;
private readonly IUserLibraryManager userLibraryManager;
public ObservableCollection<AuteurGroup> AuteurGroups { get; private set; } =
new ObservableCollection<AuteurGroup>();
private long _totalBooks;
public long TotalBooks
{
get { return _totalBooks; }
set
{
_totalBooks = value;
OnPropertyChanged();
}
}
private long _totalAuthors;
public long TotalAuthors
{
get { return _totalAuthors; }
set
{
_totalAuthors = value;
OnPropertyChanged();
}
}
public BooksViewModel(ILibraryManager data)
public ObservableCollection<AuteurGroup> AuteurGroups { get; set; }
private ICommand _removeBookCommand;
public ICommand RemoveBookCommand =>
_removeBookCommand ??= new CommandPersonnal<string>(
async (bookId) => await RemoveBookById(bookId)
);
public BooksViewModel(ILibraryManager data, IUserLibraryManager userLibraryManager)
{
this.data = data;
this.userLibraryManager = userLibraryManager;
AuteurGroups = new ObservableCollection<AuteurGroup>();
LoadBooksAsync();
}
private async void LoadBooksAsync()
public async Task LoadBooksAsync()
{
try
{
var (totalA, authors) = await data.GetAuthorsByName("", 0, 5);
TotalAuthors = totalA;
foreach (Author author in authors)
{
var books = data.GetBooksByAuthor(author.Name, 0, 5).Result.Item2;
var (totalB, books) = data.GetBooksByAuthor(author.Name, 0, 5).Result;
TotalBooks += totalB;
var observableBooks = new ObservableCollection<Book>(books);
AuteurGroups.Add(new AuteurGroup(author.Name, observableBooks));
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
Debug.WriteLine(ex.Message);
}
}
@ -45,5 +83,29 @@ namespace VMWrapper
Name = name;
}
}
public async Task RemoveBookById(string bookId)
{
await userLibraryManager.RemoveBook(bookId);
for (int i = AuteurGroups.Count - 1; i >= 0; i--)
{
var group = AuteurGroups[i];
var bookToRemove = group.FirstOrDefault(book => book.Id == bookId);
if (bookToRemove != null)
{
group.Remove(bookToRemove);
if (group.Count == 0)
{
AuteurGroups.RemoveAt(i);
}
break;
}
}
OnPropertyChanged(nameof(AuteurGroups));
}
}
}

@ -8,11 +8,19 @@ namespace VMWrapper
{
private readonly ILibraryManager data;
private readonly IUserLibraryManager userLibraryManager;
public Book BookDetail { get; private set; } = new Book();
public DetailBookViewModel(ILibraryManager data)
public DetailBookViewModel(ILibraryManager data, IUserLibraryManager userLibraryManager)
{
this.data = data;
this.userLibraryManager = userLibraryManager;
}
public async void UpdateColleciton()
{
await userLibraryManager.UpdateBook(BookDetail);
}
public async Task LoadBookDetail(string idBook)

@ -1,5 +0,0 @@
namespace VMWrapper
{
// All the code in this file is only included on Android.
public class PlatformClass1 { }
}

@ -1,5 +0,0 @@
namespace VMWrapper
{
// All the code in this file is only included on Mac Catalyst.
public class PlatformClass1 { }
}

@ -1,7 +0,0 @@
using System;
namespace VMWrapper
{
// All the code in this file is only included on Tizen.
public class PlatformClass1 { }
}

@ -1,5 +0,0 @@
namespace VMWrapper
{
// All the code in this file is only included on Windows.
public class PlatformClass1 { }
}

@ -1,5 +0,0 @@
namespace VMWrapper
{
// All the code in this file is only included on iOS.
public class PlatformClass1 { }
}

@ -1,20 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0;net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>

Loading…
Cancel
Save