Esempio n. 1
0
 public List<Post> GetAllPosts()
 {
     using (var db = new BlogContext())
     {
         var posts = db.Posts.ToList();
         return posts;
     }
 }
Esempio n. 2
0
 public void ClearPosts()
 {
     if (GetAllPosts().Any())
     {
         using (var db = new BlogContext())
         {
             db.Database.ExecuteSqlCommand("TRUNCATE TABLE [Post]");
         }
     }
 }
 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;
 }
Esempio n. 5
0
 public UserRepository(BlogContext context) : base(context)
 {
 }