Example #1
0
        public List <PostCardDTO> MapPostCardEntitiesToDTOs(List <PostEntity> postEntities)
        {
            if (postEntities == null)
            {
                return(null);
            }

            List <PostCardDTO> postCardDTOs = new List <PostCardDTO>();

            foreach (PostEntity postEntity in postEntities)
            {
                PostCardDTO postCardDTO = MapPostCardEntityToDTO(postEntity);
                postCardDTOs.Add(postCardDTO);
            }

            return(postCardDTOs);
        }
Example #2
0
        public PostCardDTO MapPostCardEntityToDTO(PostEntity postEntity)
        {
            if (postEntity == null)
            {
                return(null);
            }

            CategoryEntity categoryEntity = postEntity.PostCategory;

            PostCardDTO postCardDTO = new PostCardDTO()
            {
                PostId            = postEntity.PostId,
                Title             = postEntity.Title,
                CreatedDate       = postEntity.CreatedDate,
                UpdatedDate       = postEntity.UpdatedDate,
                ShortDescription  = postEntity.ShortDescription,
                ThumbnailImageSrc = postEntity.ThumbnailImageSrc,
                PostCategory      = MapCategoryEntityToDTO(categoryEntity),
                CommentCount      = postEntity.CommentCount
            };

            return(postCardDTO);
        }