示例#1
0
 public static Author ToModel(this AuthorAddDTO dto)
 {
     return(new Author
     {
         Name = dto.Name,
         AuthorBooks = dto.AuthorBooks?.Select(x => BookAuthorGetMap.ToModel(x)).ToArray()
     });
 }
示例#2
0
 public static AuthorAddDTO ToDTO(this Author model)
 {
     return(new AuthorAddDTO
     {
         Name = model.Name,
         AuthorBooks = model.AuthorBooks?.Select(x => BookAuthorGetMap.ToDTO(x)).ToArray()
     });
 }
示例#3
0
 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]
     });
 }
示例#4
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]
     });
 }