public static Author ToModel(this AuthorAddDTO dto) { return(new Author { Name = dto.Name, AuthorBooks = dto.AuthorBooks?.Select(x => BookAuthorGetMap.ToModel(x)).ToArray() }); }
public static AuthorAddDTO ToDTO(this Author model) { return(new AuthorAddDTO { Name = model.Name, AuthorBooks = model.AuthorBooks?.Select(x => BookAuthorGetMap.ToDTO(x)).ToArray() }); }
public static AuthorGetDTO ToDTO(this Author model, bool withLinks = true) { return(new AuthorGetDTO { Id = model.Id, Name = model.Name, AuthorBooks = model.AuthorBooks?.Select(x => BookAuthorGetMap.ToDTO(x)).ToArray(), Books = withLinks ? model.Books?.Select(x => BookGetMap.ToDTO(x, false)).ToArray() : new BookGetDTO[0] }); }
public static BookGetDTO ToDTO(this Book model, bool withLinks = true) { return(new BookGetDTO { Id = model.Id, Title = model.Title, CoverImagePath = model.CoverImagePath, Description = model.Description, BookAuthors = model.AuthorBooks?.Select(x => BookAuthorGetMap.ToDTO(x)).ToArray(), Authors = withLinks ? model.Authors?.Select(x => AuthorGetMap.ToDTO(x, false)).ToArray() : new AuthorGetDTO[0] }); }