using HomeLibrary.Api.Entities; using HomeLibrary.Models.Dtos; namespace HomeLibrary.Api.Extensions { public static class DtoConversions { public static IEnumerable ConvertToDto(this IEnumerable books, IEnumerable authors) { return (from book in books join author in authors on book.AuthorId equals author.Id select new CompleteBookDto { BookId = book.Id, AuthorId = author.Id, AuthorName = author.Name, Title = book.Title, Series = book.Series, BookNumber = book.BookNumber }).ToList(); } public static IEnumerable ConvertToDto(this IEnumerable books) { return (from book in books select new BookDto { Id = book.Id, AuthorId = book.AuthorId, Title = book.Title, Series = book.Series, BookNumber = book.BookNumber }).ToList(); } } }