Beispiel #1
0
 public IEnumerable <post> WyswietlPosty()
 {
     using (LinqBlogDataContext dp = new LinqBlogDataContext())
     {
         return((from p in dp.posts where p.status == 1 && p.data_dodania.Month == DateTime.Now.Month orderby p.ID descending select p).ToList <post>());
     }
 }
Beispiel #2
0
 public post WyswietlPostPoID(int id)
 {
     using (LinqBlogDataContext dp = new LinqBlogDataContext())
     {
         return(dp.posts.Single(p => p.ID == id));
     }
 }
Beispiel #3
0
 public List <post> WyswietlTytul(string slowo)
 {
     using (LinqBlogDataContext dp = new LinqBlogDataContext())
     {
         var PostyT = from p in dp.posts where p.tytul == slowo select p;
         return(PostyT.ToList <post>());
     }
 }
Beispiel #4
0
 public List <post> WyswietlPoTagach(string slowo)
 {
     using (LinqBlogDataContext dp = new LinqBlogDataContext())
     {
         var PostyPoSlowie = from p in dp.posts where p.tagi.keywords == slowo select p;
         return(PostyPoSlowie.ToList <post>());
     }
 }
Beispiel #5
0
 public List <post> WyswietlPoDacie(int id)
 {
     using (LinqBlogDataContext dp = new LinqBlogDataContext())
     {
         var PostyPoDacie = from p in dp.posts where p.data_dodania.Month == id select p;
         return(PostyPoDacie.ToList <post>());
     }
 }
Beispiel #6
0
 public void EdytujPost(post new_post)
 {
     using (LinqBlogDataContext dp = new LinqBlogDataContext())
     {
         var e = dp.posts.Single(x => x.ID == new_post.ID);
         e.tytul            = new_post.tytul;
         e.tresc            = new_post.tresc;
         e.status           = new_post.status;
         e.data_modyfikacji = DateTime.Now;
         dp.SubmitChanges();
     }
 }
Beispiel #7
0
 public post EdytujPost(int id)
 {
     using (LinqBlogDataContext dp = new LinqBlogDataContext())
     {
         try
         {
             return(dp.posts.Single(p => p.ID == id));
         }
         catch
         {
             return(null);
         }
     }
 }
Beispiel #8
0
        public void DodajPost(Klasa new_post)
        {
            using (LinqBlogDataContext dp = new LinqBlogDataContext())
            {
                var p = new post();
                p.tytul        = new_post.tytul;
                p.tresc        = new_post.tresc;
                p.status       = new_post.status;
                p.data_dodania = DateTime.Now;
                dp.posts.InsertOnSubmit(p);
                dp.SubmitChanges();

                var t = new tagi();
                t.id_posta    = p.ID;
                t.keywords    = new_post.keywords;
                t.description = new_post.description;
                dp.tagis.InsertOnSubmit(t);
                dp.SubmitChanges();
            }
        }