You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.1 KiB
83 lines
2.1 KiB
using Model;
|
|
using System.Collections.ObjectModel;
|
|
using ToolKit;
|
|
using static System.Reflection.Metadata.BlobBuilder;
|
|
|
|
namespace Wrapper
|
|
{
|
|
public class LoanViewModel : BaseViewModel
|
|
{
|
|
IUserLibraryManager UserLibraryManager;
|
|
|
|
WorkOnListBooks WorkOnListBooks { get; set; }
|
|
|
|
//------------------------------------------------------------//
|
|
|
|
public ObservableCollection<Book> LoansBook = new ObservableCollection<Book>();
|
|
public ObservableCollection<GroupBooks> LoanGroupBooks { get; private set; } = new ObservableCollection<GroupBooks>();
|
|
|
|
//------------------------------------------------------------//
|
|
|
|
public LoanViewModel(IUserLibraryManager userLibraryManager,WorkOnListBooks workOnListBooks)
|
|
{
|
|
this.UserLibraryManager = userLibraryManager;
|
|
this.WorkOnListBooks = workOnListBooks;
|
|
|
|
InitiateParam();
|
|
}
|
|
|
|
private void InitiateParam()
|
|
{
|
|
Index = 0;
|
|
Count = 7;
|
|
}
|
|
|
|
private void LoadBooksLoan()
|
|
{
|
|
var result = UserLibraryManager.GetBooksFromCollection(index, count, "");
|
|
if (result.Result.Item2.Count() == 0) { return; }
|
|
Books.Clear();
|
|
foreach (Book book in result.Result.Item2)
|
|
{
|
|
Books.Add(book);
|
|
}
|
|
|
|
List<GroupBooks> groupeBook = WorkOnListBooks.UpdateGroupBooks(Books.ToList());
|
|
if (groupeBook.Count > 0)
|
|
{
|
|
GroupBooks.Clear();
|
|
foreach (GroupBooks groupeBookUnique in groupeBook)
|
|
{
|
|
GroupBooks.Add(groupeBookUnique);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public int Index
|
|
{
|
|
get { return index; }
|
|
private set
|
|
{
|
|
setProperty(ref index, value);
|
|
}
|
|
|
|
}
|
|
private int index;
|
|
|
|
|
|
|
|
public int Count
|
|
{
|
|
get { return count; }
|
|
private set
|
|
{
|
|
setProperty(ref count, value);
|
|
}
|
|
|
|
}
|
|
private int count;
|
|
}
|
|
}
|