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); }
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); }