public static UserSubscriptionsDto Build(List <ApplicationUser> following, List <ApplicationUser> followers, int totalUserSubscriptionsCount, PathString requestPath,
                                                 int page, int pageSize)
        {
            List <UserBasicEmbeddedInfoDto> followingDtoList = new List <UserBasicEmbeddedInfoDto>(following.Count);
            List <UserBasicEmbeddedInfoDto> followersDtoList = new List <UserBasicEmbeddedInfoDto>(followers.Count);

            foreach (var user in following)
            {
                followingDtoList.Add(UserBasicEmbeddedInfoDto.Build(user));
            }

            foreach (var user in followers)
            {
                followingDtoList.Add(UserBasicEmbeddedInfoDto.Build(user));
            }

            return(new UserSubscriptionsDto
            {
                PageMeta = new PageMeta(followingDtoList.Count + followers.Count, requestPath, currentPage: page,
                                        pageSize: pageSize,
                                        totalItemCount: totalUserSubscriptionsCount),
                Following = followingDtoList,
                Followers = followersDtoList
            });
        }
Esempio n. 2
0
        // 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);
        }
    }
Esempio n. 3
0
        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(
                    new CommentDetailsDto
                {
                    Article = new ArticleIdSlugAndTitle
                    {
                        Id    = comment.ArticleId,
                        Title = comment.Article.Title,
                        Slug  = comment.Article.Slug,
                    },
                    IsReply          = comment.IsReply,
                    RepliedCommentId = comment.RepliedCommentId,
                    Content          = comment.Content,
                    CreatedAt        = comment.CreatedAt,
                    User             = UserBasicEmbeddedInfoDto.Build(comment.User)
                });
            }

            return(new CommentListDto
            {
                Success = true,
                PageMeta = new PageMeta(result.Count, basePath, currentPage: currentPage, pageSize: pageSize,
                                        totalItemCount: totalItemCount),
                Comments = result
            });
        }
Esempio n. 4
0
 //public Comment Comment {get; set;}
 public static CommentIntrinsicInfoDto Build(Entities.Comment comment)
 {
     return(new CommentIntrinsicInfoDto
     {
         Content = comment.Content,
         User = UserBasicEmbeddedInfoDto.Build(comment.User),
         CreatedAt = comment.CreatedAt,
         UpdatedAt = comment.UpdatedAt
     });
 }
Esempio n. 5
0
 public static ArticleSummaryDto Build(Entities.Article article)
 {
     return(new ArticleSummaryDto
     {
         Id = article.Id,
         Title = article.Title,
         Slug = article.Slug,
         Description = article.Description,
         CommentsCount = article.CommentsCount,
         Categories = CategoryOnlyNameDto.BuildAsStringList(article.ArticleCategories),
         User = UserBasicEmbeddedInfoDto.Build(article.User),
         Tags = TagOnlyNameDto.BuildAsStringList(article.ArticlesTags),
         PublishAt = article.PublishedOn,
         UpdatedAt = article.UpdatedAt
     });
 }
Esempio n. 6
0
        public static OrderDto Build(Order order, bool includeUser = false)
        {
            var dto = new OrderDto
            {
                Id             = order.Id,
                TrackingNumber = order.TrackingNumber,
                OrderStatus    = order.OrderStatus,
                Address        = AddressDto.Build(order.Address),
            };

            if (includeUser)
            {
                dto.User = UserBasicEmbeddedInfoDto.Build(order.User);
            }

            return(dto);
        }
        public static AddressDto Build(Address address, bool includeUser = false)
        {
            var dto = new AddressDto
            {
                Id        = address.Id,
                City      = address.City,
                Country   = address.Country,
                ZipCode   = address.ZipCode,
                FirstName = address.FirstName,
                LastName  = address.LastName,
                Address   = address.StreetAddress
            };

            if (includeUser)
            {
                dto.User = UserBasicEmbeddedInfoDto.Build(address.User);
            }
            return(dto);
        }
 // public Comment Comment {get; set;}
 public static CommentDetailsDto Build(Entities.Comment comment)
 {
     return(new CommentDetailsDto
     {
         // ArticleSlug = comment.Article.Slug,
         // ArticleId = comment.ArticleId,
         Article = new ArticleIdSlugAndTitle
         {
             Id = comment.ArticleId,
             Title = comment.Article.Title,
             Slug = comment.Article.Slug,
         },
         Content = comment.Content,
         User = UserBasicEmbeddedInfoDto.Build(comment.User),
         IsReply = comment.RepliedComment != null,
         RepliedCommentId = comment.RepliedCommentId,
         CreatedAt = comment.CreatedAt,
         UpdatedAt = comment.UpdatedAt
     });
 }
Esempio n. 9
0
        public static LikesListDto Build(List <Like> likes, PathString requestPath, int page, int requestedPageSize,
                                         int totalLikesCount, bool includeUser = true)
        {
            List <LikeSummaryDto> articleSummaryDtos = new List <LikeSummaryDto>(likes.Count);

            foreach (var like in likes)
            {
                articleSummaryDtos.Add(new LikeSummaryDto
                {
                    Article = ArticleIdSlugAndTitle.Build(like.Article),
                    User    = includeUser && like.User != null ? null : UserBasicEmbeddedInfoDto.Build(like.User)
                });
            }

            return(new LikesListDto
            {
                PageMeta = new PageMeta(likes.Count, requestPath, currentPage: page, pageSize: requestedPageSize,
                                        totalItemCount: totalLikesCount),
                Likes = articleSummaryDtos
            });
        }
Esempio n. 10
0
        public static ArticleDetailsDto Build(Entities.Article article)
        {
            var commentDtos = new List <CommentDetailsDto>();

            foreach (var comment in article.Comments)
            {
                commentDtos.Add(CommentDetailsDto.Build(comment));
            }

            return(new ArticleDetailsDto
            {
                Id = article.Id,
                Slug = article.Slug,
                Title = article.Slug,
                Body = article.Body,
                PublishedAt = article.PublishedOn,
                Comments = commentDtos,
                User = UserBasicEmbeddedInfoDto.Build(article.User),
                Tags = TagOnlyNameDto.BuildAsStringList(article.ArticlesTags),
                Categories = CategoryOnlyNameDto.BuildAsStringList(article.ArticleCategories),
            });
        }