예제 #1
0
 public List<Post> GetAllPosts()
 {
     using (var db = new BlogContext())
     {
         var posts = db.Posts.ToList();
         return posts;
     }
 }
예제 #2
0
 public void ClearPosts()
 {
     if (GetAllPosts().Any())
     {
         using (var db = new BlogContext())
         {
             db.Database.ExecuteSqlCommand("TRUNCATE TABLE [Post]");
         }
     }
 }
예제 #3
0
 public ActionResult Create(Post post)
 {
     post.Author = Application.CurrentUser.Name;
     post.State = "Draft";
     using (var db = new BlogContext())
     {
         db.Posts.Add(post);
         db.SaveChanges();
     }
     return RedirectToAction("Index");
 }
 public UnitOfWork(BlogContext blogContext)
 {
     _blogContext = blogContext;
 }
예제 #5
0
 public UserRepository(BlogContext context) : base(context)
 {
 }