// public Comment Comment {get; set;} public static CommentDetailsDto Build(Comment comment, bool includeProduct = false, bool includeUser = false) { var dto = new CommentDetailsDto { Id = comment.Id, Content = comment.Content, Rating = comment.Rating, CreatedAt = comment.CreatedAt, UpdatedAt = comment.UpdatedAt }; if (includeProduct) { dto.Product = new ProductElementalDto { Id = comment.ProductId, Name = comment.Product.Name, Slug = comment.Product.Slug, } } ; if (includeUser) { dto.User = UserBasicEmbeddedInfoDto.Build(comment.User); } return(dto); } }
public static CommentListDto Build(ICollection <Entities.Comment> comments, string basePath, int currentPage, int pageSize, int totalItemCount) { ICollection <CommentDetailsDto> result = new List <CommentDetailsDto>(); foreach (var comment in comments) { result.Add(CommentDetailsDto.Build(comment, false, true)); } return(new CommentListDto { Success = true, PageMeta = new PageMeta(result.Count, basePath, currentPageNumber: currentPage, requestedPageSize: pageSize, totalItemCount: totalItemCount), Comments = result }); }