Exemplo n.º 1
0
 public void Add(Page webpage)
 {
     using (var context = new QueensOfCodeDbContext())
     {
         context.Pages.Add(webpage);
         context.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public IEnumerable <Page> GetAllPages()
 {
     using (var context = new QueensOfCodeDbContext())
     {
         var page = context.Pages;
         return(page.ToList());
     }
 }
Exemplo n.º 3
0
 public Page GetPageById(int id)
 {
     using (var context = new QueensOfCodeDbContext())
     {
         var page = context.Pages.FirstOrDefault(p => p.Id == id);
         return(page);
     }
 }
Exemplo n.º 4
0
 public IEnumerable <Post> GetAllPosts()
 {
     using (var context = new QueensOfCodeDbContext())
     {
         var post = context.Posts;
         return(post.ToList());
     }
 }
Exemplo n.º 5
0
 public void Add(Post blog)
 {
     using (var context = new QueensOfCodeDbContext())
     {
         context.Posts.Add(blog);
         context.SaveChanges();
     }
 }
Exemplo n.º 6
0
 public Post GetPostById(int id)
 {
     using (var context = new QueensOfCodeDbContext())
     {
         var post = context.Posts.FirstOrDefault(p => p.Id == id);
         return(post);
     }
 }
Exemplo n.º 7
0
 public void Delete(int id)
 {
     using (var context = new QueensOfCodeDbContext())
     {
         var page = context.Pages.FirstOrDefault(p => p.Id == id);
         context.Pages.Remove(page);
         context.SaveChanges();
     }
 }
Exemplo n.º 8
0
        public void Edit(Page webpage)
        {
            using (var context = new QueensOfCodeDbContext())
            {
                var page = context.Pages.FirstOrDefault(p => p.Id == webpage.Id);

                page.Title         = webpage.Title;
                page.PostText      = webpage.PostText;
                page.ImageFilePath = webpage.ImageFilePath;
                page.Id            = webpage.Id;

                context.SaveChanges();
            }
        }
Exemplo n.º 9
0
        public void Edit(Post blog)
        {
            using (var context = new QueensOfCodeDbContext())
            {
                var post = context.Posts.FirstOrDefault(p => p.Id == blog.Id);

                post.Title          = blog.Title;
                post.PostText       = blog.PostText;
                post.ExpirationDate = blog.ExpirationDate;
                post.Featured       = blog.Featured;
                post.Visible        = blog.Visible;
                post.CreationDate   = blog.CreationDate;
                post.ImageFilePath  = blog.ImageFilePath;
                post.Id             = blog.Id;

                context.SaveChanges();
            }
        }