예제 #1
0
        private void ResetAuthors(int bookId, IEnumerable <AuthorInBook> authorInBookList)
        {
            var authorInBookRepo = new AuthorInBookRepository(dapperConnectionFactory);

            authorInBookRepo.GetByBookId(bookId).ToList().ForEach(ainb =>
                                                                  authorInBookRepo.Delete(ainb)
                                                                  );
            authorInBookList?.ToList().ForEach(ainb =>
            {
                authorInBookRepo.Create(new AuthorInBook {
                    Book_Id = bookId, Author_Id = ainb.Author_Id
                });
            });
        }
예제 #2
0
        private IEnumerable <GetBookResponseModel> ToResponseModel(IEnumerable <Book> source)
        {
            var authorInBookRepository  = new AuthorInBookRepository(dapperConnectionFactory);
            var publishedBookRepository = new PublishedBookRepository(dapperConnectionFactory);
            IEnumerable <GetBookResponseModel> response = source.Select(book =>
            {
                return(new GetBookResponseModel
                {
                    Id = book.Id,
                    AdditionalData = book.AdditionalData,
                    Capation = book.Capation,
                    ISBN = book.ISBN,
                    Authors = authorInBookRepository.GetAuthorInBookResponseModelByBookId(book.Id),
                    PublishedBooks = publishedBookRepository.GetPublishedBookByBookId(book.Id)
                });
            });

            return(response);
        }
예제 #3
0
        private IEnumerable <GetAuthorResponseModel> ToResponseModel(IEnumerable <Author> source)
        {
            var authorInBookRepository = new AuthorInBookRepository(dapperConnectionFactory);
            IEnumerable <GetAuthorResponseModel> response = source.Select(author =>
            {
                return(new GetAuthorResponseModel
                {
                    Id = author.Id,
                    DateOfBirth = author.DateOfBirth,
                    DateOfDeath = author.DateOfDeath,
                    FirstName = author.FirstName,
                    Patronymic = author.Patronymic,
                    SecondName = author.SecondName,
                    Books = authorInBookRepository.GetAuthorInBookResponseModelByAuthorId(author.Id)
                });
            });

            return(response);
        }
예제 #4
0
        public GetAuthorResponseModel GetAuthorResponseModel(int id)
        {
            var authorInBookRepo = new AuthorInBookRepository(dapperConnectionFactory);

            Author author = base.Get(id);
            IEnumerable <AuthorInBook> ainbList = authorInBookRepo.GetByAuthorId(id);
            GetAuthorResponseModel     response = new GetAuthorResponseModel
            {
                DateOfBirth = author.DateOfBirth,
                DateOfDeath = author.DateOfDeath,
                FirstName   = author.FirstName,
                Id          = author.Id,
                Patronymic  = author.Patronymic,
                SecondName  = author.SecondName,
                Books       = authorInBookRepo.GetAuthorInBookResponseModelByAuthorId(author.Id)
            };

            return(response);
        }