private void GetBooksUserHasReadOrViewed(Guid userId)
        {
            var bookPagesUserOpened = _userOpndBookPageService
                                      .AsQueryable()
                                      .Where(x => x.UserId == userId)
                                      .ToList();

            _booksUserRead = _booksReadService
                             .AsQueryable()
                             .Include(x => x.Book)
                             .Where(x => x.UserId == userId)
                             .ToList();

            GetBookIdsWhichUserViewedOrRead(bookPagesUserOpened, _booksUserRead);

            _allBooks = _bookService
                        .AsQueryable()
                        .Include(x => x.Genre)
                        .Include(x => x.BookAuthors)
                        .ToList();

            foreach (var id in _bookIds)
            {
                _booksUserReadOrViewed.Add(_allBooks
                                           .AsQueryable()
                                           .Include(x => x.Genre)
                                           .Include(x => x.BookAuthors)
                                           .Where(x => x.Id == id)
                                           .FirstOrDefault());
            }
        }
        private bool ReadXAmountOfBooks(Guid userId, int amount)
        {
            var count = _booksReadService
                        .AsQueryable()
                        .Where(x => x.UserId == userId)
                        .Count();

            if (count >= amount)
            {
                return(true);
            }

            return(false);
        }
Пример #3
0
        public ActionResult <BooksRead> Get(Guid id)
        {
            var item = _booksReadService.AsQueryable()
                       .Where(x => x.Id == id)
                       .FirstOrDefault();

            if (item is null)
            {
                return(NoContent());
            }

            return(Ok(item));
        }