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); }
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); }