Ejemplo n.º 1
0
        // Typing/Index?bookid=3&bookPage=2
        // Typing?bookid=3&bookPage=2
        public IActionResult Index(int bookID = _defaultBook, int bookPage = 0)
        {
            var book = _context.Book.Find(bookID);

            if (bookID == 1)
            {
                ViewBag.IsIntroduction = true;
            }

            var typingHelper = new TypingHelper();
            var bookPages    = typingHelper.DivideBook(book.BookContent);

            var authorNamesHelper = new GetAuthorsFullNameListHelper(_context);
            var authorsList       = _context.Book.Where(x => x.ID == bookID)
                                    .SelectMany(x => x.BookAuthors)
                                    .Select(x => x.Author)
                                    .ToList();
            var bookAuthors = authorNamesHelper.Get(bookID);

            var model = new TypingViewModel()
            {
                BookAuthors     = bookAuthors,
                CurrentBookPage = bookPage,
                BookPages       = bookPages,
                BookTitle       = book.BookTitle,
                BookID          = bookID
            };

            return(View(model));
        }
Ejemplo n.º 2
0
        //[Fact] TODO
        public void Test()
        {
            // Arrange
            var authorNamesHelper = new GetAuthorsFullNameListHelper(_context);

            // Act
            var bookID      = 1;
            var bookAuthors = authorNamesHelper.Get(bookID);

            // Assert
            Assert.Equal("Bob Code, John Travolta", bookAuthors);
        }