|
|
@ -1,18 +1,12 @@
|
|
|
|
using Model;
|
|
|
|
using Model;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
using System.Windows.Input;
|
|
|
|
using ToolKit;
|
|
|
|
using ToolKit;
|
|
|
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace VMWrapper
|
|
|
|
namespace VMWrapper
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class FilterViewModel: BaseViewModel
|
|
|
|
public class FilterViewModel : BaseViewModel
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly ILibraryManager data;
|
|
|
|
private readonly ILibraryManager data;
|
|
|
|
|
|
|
|
|
|
|
@ -21,7 +15,6 @@ namespace VMWrapper
|
|
|
|
public ObservableCollection<Book> BookList { get; private set; } =
|
|
|
|
public ObservableCollection<Book> BookList { get; private set; } =
|
|
|
|
new ObservableCollection<Book>();
|
|
|
|
new ObservableCollection<Book>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private long _totalBooks;
|
|
|
|
private long _totalBooks;
|
|
|
|
public long TotalBooks
|
|
|
|
public long TotalBooks
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -46,7 +39,6 @@ namespace VMWrapper
|
|
|
|
_ = SearchAuthors(SearchQuery);
|
|
|
|
_ = SearchAuthors(SearchQuery);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _searchCommand;
|
|
|
|
private ICommand _searchCommand;
|
|
|
@ -55,6 +47,12 @@ namespace VMWrapper
|
|
|
|
async (query) => await SearchAuthors(query)
|
|
|
|
async (query) => await SearchAuthors(query)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ICommand _sortCommand;
|
|
|
|
|
|
|
|
public ICommand SortCommand =>
|
|
|
|
|
|
|
|
_sortCommand ??= new CommandPersonnal<string>(
|
|
|
|
|
|
|
|
async (sortOrder) => await SortingByName(sortOrder)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
public FilterViewModel(ILibraryManager data)
|
|
|
|
public FilterViewModel(ILibraryManager data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.data = data;
|
|
|
|
this.data = data;
|
|
|
@ -99,6 +97,46 @@ namespace VMWrapper
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task SortingByName(string sortOrder)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
string sortParam = sortOrder switch
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"name" => "name",
|
|
|
|
|
|
|
|
"name_reverse" => "name_reverse",
|
|
|
|
|
|
|
|
_ => "name"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
Debug.WriteLine($"riri", sortOrder);
|
|
|
|
|
|
|
|
if (SearchQuery != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var (total, authors) = await data.GetAuthorsByName(
|
|
|
|
|
|
|
|
_searchQuery,
|
|
|
|
|
|
|
|
0,
|
|
|
|
|
|
|
|
10,
|
|
|
|
|
|
|
|
sortParam
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
AuthorList.Clear();
|
|
|
|
|
|
|
|
foreach (var author in authors)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
AuthorList.Add(author);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var (total, authors) = await data.GetAuthorsByName("", 0, 10, sortParam);
|
|
|
|
|
|
|
|
AuthorList.Clear();
|
|
|
|
|
|
|
|
foreach (var author in authors)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
AuthorList.Add(author);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Debug.WriteLine(ex.Message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async Task SearchAuthors(string query)
|
|
|
|
private async Task SearchAuthors(string query)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -107,7 +145,7 @@ namespace VMWrapper
|
|
|
|
if (!string.IsNullOrWhiteSpace(query))
|
|
|
|
if (!string.IsNullOrWhiteSpace(query))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TotalBooks = 0;
|
|
|
|
TotalBooks = 0;
|
|
|
|
|
|
|
|
|
|
|
|
var (total, authors) = await data.GetAuthorsByName(query, 0, 10);
|
|
|
|
var (total, authors) = await data.GetAuthorsByName(query, 0, 10);
|
|
|
|
|
|
|
|
|
|
|
|
AuthorList.Clear();
|
|
|
|
AuthorList.Clear();
|
|
|
@ -115,7 +153,6 @@ namespace VMWrapper
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var (totalB, books) = data.GetBooksByAuthor(author.Name, 0, 10).Result;
|
|
|
|
var (totalB, books) = data.GetBooksByAuthor(author.Name, 0, 10).Result;
|
|
|
|
TotalBooks += totalB;
|
|
|
|
TotalBooks += totalB;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var author in authors)
|
|
|
|
foreach (var author in authors)
|
|
|
|