public AuthorDto CreateAuthorWithBooks(AuthorForCreationDto authorForCreationDto) { string authorId = Guid.NewGuid().ToString(); var author = CreateAuthor(authorForCreationDto, authorId); _bookService.CreateBooks(authorForCreationDto.Books, authorId); return(author); }
public AuthorDto CreateAuthor(AuthorForCreationDto authorForCreationDto, string authorId = null) { if (string.IsNullOrEmpty(authorId)) { authorId = Guid.NewGuid().ToString(); } _authorRepository.CreateAuthor(authorForCreationDto, authorId); if (authorForCreationDto.Books.Count > 0) { _bookService.CreateBooks(authorForCreationDto.Books, authorId); } var authorToReturn = _mapper.Map <AuthorDto>(authorForCreationDto); authorToReturn.Id = authorId; return(authorToReturn); }