//Материализует Post и преобразывает его во PostView static PostView postToPostView(Post post) { PostView postView = new PostView(); if (post != null) { postView.Header = post.Header ?? " "; if (post.Image!=null) { postView.id_image = post.Image.Id_image; } postView.id_post = post.Id_post; postView.tags = post.Tags.Select(tag => tag.name).ToList(); postView.textContent = post.Text ?? ""; postView.username = post.User.Login ?? ""; return postView; } else { throw new PostNotExistException(); } }
//Материализует Post и преобразывает его во PostView static PostView postToPostView(Post post) { PostView postView = new PostView(); if (post != null) { postView.Header = post.Header ?? " "; if (post.Image != null) { postView.id_image = post.Image.Id_image; } postView.id_post = post.Id_post; postView.tags = post.Tags.Select(tag => tag.name).ToList(); postView.textContent = post.Text ?? ""; postView.username = post.User.Login ?? ""; return(postView); } else { throw new PostNotExistException(); } }