Exemple #1
0
        private Books MapBook(BookEntity entry)
        {
            var book = new Books
            {
                Isbn      = entry.Isbn,
                LauchDate = entry.LauchDate,
                Title     = entry.Title,
                Id        = entry.Id
            };

            if (entry.Authors != null && entry.Authors.Count > 0)
            {
                var authorBooks = new List <AuthorBook>();
                foreach (var author in entry.Authors)
                {
                    var authorBook = new AuthorBook
                    {
                        AuthorId = author.Id,
                        BookId   = entry.Id
                    };
                    authorBooks.Add(authorBook);
                }
                book.AuthorBook = authorBooks;
            }

            return(book);
        }
Exemple #2
0
        private Author MapAuthor(AuthorEntity entry)
        {
            var author = new Author
            {
                Name      = entry.Name,
                LastName  = entry.LastName,
                Email     = entry.Email,
                Birthdate = entry.Birthdate,
                Id        = entry.Id
            };

            if (entry.Books != null && entry.Books.Count > 0)
            {
                var authorBooks = new List <AuthorBook>();
                foreach (var book in entry.Books)
                {
                    var authorBook = new AuthorBook
                    {
                        AuthorId = entry.Id,
                        BookId   = book.Id
                    };
                    authorBooks.Add(authorBook);
                }
                author.AuthorBook = authorBooks;
            }

            return(author);
        }