BloggingSystem.Services.DataMappers.PostsMapper.ToModel C# (CSharp) 메소드

ToModel() 공개 정적인 메소드

public static ToModel ( Post postEntity ) : PostModel
postEntity BloggingSystem.Models.Post
리턴 BloggingSystem.DataTransferObjects.PostModel
        public static PostModel ToModel(Post postEntity)
        {
            PostModel postModel = new PostModel()
            {
                ID = postEntity.ID,
                Title = postEntity.Title,
                Text = postEntity.Text,
                PostDate = postEntity.PostDate,
                Author = postEntity.Author.DisplayName
            };

            foreach (var commentEntity in postEntity.Comments)
            {
                postModel.Comments.Add(CommentsMapper.ToModel(commentEntity));
            }

            foreach (var tag in postEntity.Tags)
            {
                postModel.Tags.Add(tag.Name);
            }

            return postModel;
        }