Esempio n. 1
0
        public List <APICommentModel> MapCommentDTOsToModels(List <CommentDTO> commentDTOs)
        {
            if (commentDTOs == null)
            {
                return(null);
            }

            List <APICommentModel> commentModels = new List <APICommentModel>();

            foreach (CommentDTO commentDTO in commentDTOs)
            {
                APICommentModel commentModel = MapCommentDTOToModel(commentDTO);
                commentModels.Add(commentModel);
                List <CommentDTO> childCommentDTOs = commentDTO.ChildCommentDTOs;

                if (childCommentDTOs == null)
                {
                    continue;
                }

                List <APICommentModel> childCommentModels = new List <APICommentModel>();

                foreach (CommentDTO childCommentDTO in childCommentDTOs)
                {
                    APICommentModel childAPICommentModel = MapCommentDTOToModel(childCommentDTO);
                    childCommentModels.Add(childAPICommentModel);
                }

                commentModel.ChildCommentModels = childCommentModels;
            }

            return(commentModels);
        }
Esempio n. 2
0
        public APICommentModel MapCommentDTOToModel(CommentDTO commentDTO)
        {
            if (commentDTO == null)
            {
                return(null);
            }

            APICommentModel commentModel = new APICommentModel()
            {
                CommentId   = commentDTO.CommentId,
                Username    = commentDTO.Username,
                Content     = commentDTO.Content,
                CreatedDate = FormatTime(commentDTO.CreatedDate)
            };

            return(commentModel);
        }