Пример #1
0
 private static void AddTagsToExistingPost(BlogDBContext db,Posts post, IEnumerable<Tags> tags)
 {
     foreach (var tag in tags)
     {
         post.Tags.Add(tag);
         tag.Posts.Add(post);
     }
     post.Body += " added new tag";
     db.SaveChanges();
 }
Пример #2
0
 private static void CreatePost(BlogDBContext db)
 {
     var post = new Posts()
     {
         AuthorId = db.Users.OrderByDescending(u => u.Id).First().Id,
         Body = "new post body new post body new post body new post body new post body ",
         Title = "new post title",
         Date = DateTime.Now
     };
     db.Posts.Add(post);
     db.SaveChanges();
 }