Example #1
0
        private async Task SearchViewModelMapper(SearchViewModel searchVM, IEnumerable <BookViewModel> allBookCopies, User user)
        {
            foreach (var book in allBookCopies)
            {
                if (!searchVM.AllBooks.Any(x => x.ISBN == book.ISBN))
                {
                    if (User.Identity.IsAuthenticated)
                    {
                        book.IsBookCheckedout    = _system.IsBookCheckedout(user, book.ISBN);
                        book.IsChBooksMaxQuota   = _system.IsMaxCheckedoutQuota(user);
                        book.AreAllCopiesChecked = await _system.AreAllCopiesCheckedAsync(book.ISBN);

                        book.UserStatus = user.Status.ToString();
                    }

                    book.BookCopies = await _bookManager.BookCopiesCountAsync(book.ISBN);

                    searchVM.AllBooks.Add(book);
                }
            }
        }