public Blog GetDataModel() { var blog = new Blog {BlogId = BlogId, Name = Name}; blog.Posts = new List<Post>(); Posts.ForEach(post => blog.Posts.Add(post.GetDataModel())); return blog; }
public BlogViewModel(Blog blog) { BlogId = blog.BlogId; Name = blog.Name; IsInEditMode = false; Posts = new List<PostViewModel>(); blog.Posts.OrderByDescending(x => x.PostId).ToList().ForEach(post => { var addMe = new PostViewModel(post); Posts.Add(addMe); }); }