private static BlogRecord GetRecord(String name, User owner, Blog blog, int ratings, int comments) { var result = new BlogRecord() { Comments = new List<Comment>(), Name = name, Blog = blog, Ratings = new List<Rating>() }; result.Value = "Truncation\n" + "To truncate long lines of text in an ellipsis, add the class truncate to the tag which contains the text. See an example below of a header being truncated inside a card."; for (int i = 0; i < ratings; i++) { result.Ratings.Add(new Rating() { Value = i % 2 == 0, Record = result, Owner = new User() { Login = String.Format("user_{0}", i), Password = "******" } }); } for (int i = 0; i < comments; i++) { result.Comments.Add(new Comment() { Value = String.Format("Comment_{0}", i), Owner = owner, Record = result }); } return result; }
private static Blog GetBlog(String name, User owner, int records) { var result = new Blog() { Name = name, Owner = owner, Records = new List<BlogRecord>() }; for (int i = 0; i < records; i++) result.Records.Add(GetRecord(String.Format("Record_{0}", i), owner, result, 2, 2)); return result; }
public void SaveBlog(Blog blog) { using (var session = NHibernateHelper.OpenSession()) { using (var transaction = session.BeginTransaction()) { session.SaveOrUpdate(blog); transaction.Commit(); } } }
public static void Initialize() { User user = new User() { Login = "******", Password = "******" }; Blog blog = new Blog() { Name = "Blog_1", Owner = user, Records = new List<BlogRecord>() }; //blog.Records.Add(new BlogRecord() { Value = "Record_1", System.Diagnostics.Debug.WriteLine("UserId = {0}", user.Id); repository.SaveUser(user); System.Diagnostics.Debug.WriteLine("UserId = {0}", user.Id); /*repository.SaveBlog(new Blog() { Name = "Blog_1", Owner = user }); repository.SaveBlog(new Blog() { Name = "Blog_2", Owner = user }); repository.SaveBlog(new Blog() { Name = "Blog_3", Owner = user });*/ for (int i = 0; i < 3; i++) repository.SaveBlog(GetBlog(String.Format("Blog_{0}", i), user, 2)); }