public static CollaboratorDto Convert(Collaborator collaborator) { var posts = new List <PostDto>(); if (collaborator.PostCollaborator != null) { foreach (var pc in collaborator.PostCollaborator) { pc.Post.PostTag = null; pc.Post.PostCollaborator = null; pc.Post.PostCategory = null; posts.Add(PostConverter.Convert(pc.Post)); } } return(new CollaboratorDto { Id = collaborator.Id, Name = collaborator.Name, Date = collaborator.Date, Role = collaborator.Role, Description = collaborator.Description, Links = collaborator.Links, Posts = posts }); }
public static CategoryDto Convert(Category category) { var posts = new List <PostDto>(); if (category.PostCategory != null) { foreach (var pc in category.PostCategory) { pc.Post.PostCategory = null; pc.Post.PostCollaborator = null; pc.Post.PostTag = null; posts.Add(PostConverter.Convert(pc.Post)); } } return(new CategoryDto { Id = category.Id, Name = category.Name, Posts = posts }); }
public static TagDto Convert(Tag tag) { var posts = new List <PostDto>(); if (tag.PostTag != null) { foreach (var pt in tag.PostTag) { pt.Post.PostTag = null; pt.Post.PostCollaborator = null; pt.Post.PostCategory = null; posts.Add(PostConverter.Convert(pt.Post)); } } return(new TagDto { Id = tag.Id, Name = tag.Name, Posts = posts }); }