Beispiel #1
0
        public PostEntityWithPaginatedComments GetPostWithPaginatedComments(string id, int pageSize)
        {
            try
            {
                PostEntity postEntity = Context.PostEntities
                                        .AsNoTracking()
                                        .Where(x => x.PostId.Equals(id))
                                        .Include(x => x.PostCategory)
                                        .First();

                PaginationEntity <CommentEntity> commentPaginationEntity = commentRepository.GetCommentPaginationOfPostWithPreservedFetch(postId: id, createdDate: DateTime.Now, pageSize);

                PostEntityWithPaginatedComments postEntityWithPaginatedComments = new PostEntityWithPaginatedComments()
                {
                    Post = postEntity,
                    CommentPaginationEntity = commentPaginationEntity
                };

                return(postEntityWithPaginatedComments);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #2
0
        public PostDTOWithPaginatedComments GetPostWithPaginatedComments(string id, int pageSize)
        {
            PostEntityWithPaginatedComments postEntityWithPaginatedComments = postRepository.GetPostWithPaginatedComments(id, pageSize);
            PostDTOWithPaginatedComments    postDTOWithPaginatedComments    = dataMapper.MapPostEntityToDTOWithPaginatedComments(postEntityWithPaginatedComments);

            return(postDTOWithPaginatedComments);
        }
Beispiel #3
0
        public PostDTOWithPaginatedComments MapPostEntityToDTOWithPaginatedComments(PostEntityWithPaginatedComments postEntityWithPaginatedComments)
        {
            if (postEntityWithPaginatedComments == null)
            {
                return(null);
            }

            PostEntity postEntity = postEntityWithPaginatedComments.Post;
            PaginationEntity <CommentEntity> commentPaginationEntity = postEntityWithPaginatedComments.CommentPaginationEntity;

            PostDTOWithPaginatedComments postDTOWithPaginatedComments = new PostDTOWithPaginatedComments()
            {
                Post = MapPostEntityToDTO(postEntity),
                CommentPaginationDTO = MapCommentPaginationEntityToDTO(commentPaginationEntity)
            };

            return(postDTOWithPaginatedComments);
        }