using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Model { public class Manager { private ILibraryManager LibraryManager { get; set; } public ReadOnlyCollection Books { get; private set; } private List books = new(); public Manager(ILibraryManager libMgr) { LibraryManager = libMgr; Books = new ReadOnlyCollection(books); } public async Task GetBookById(string id) => await LibraryManager.GetBookById(id); public async Task GetBookByISBN(string isbn) => await LibraryManager.GetBookByISBN(isbn); public async Task<(long count, IEnumerable books)> GetBooksByTitle(string title, int index, int count, string sort = "") { var result = await LibraryManager.GetBooksByTitle(title, index, count, sort); return (result.Item1, result.Item2); } public async Task<(long count, IEnumerable books)> GetBooksByAuthorId(string authorId, int index, int count, string sort = "") { var result = await LibraryManager.GetBooksByAuthorId(authorId, index, count, sort); return (result.Item1, result.Item2); } public async Task<(long count, IEnumerable books)> GetBooksByAuthor(string author, int index, int count, string sort = "") { var result = await LibraryManager.GetBooksByAuthor(author, index, count, sort); return (result.Item1, result.Item2); } public async Task GetAuthorById(string id) => await LibraryManager.GetAuthorById(id); public async Task<(long count, IEnumerable authors)> GetAuthorsByName(string substring, int index, int count, string sort = "") { var result = await LibraryManager.GetAuthorsByName(substring, index, count, sort); return (result.Item1, result.Item2); } } }