상속: System.Data.Linq.DataContext
예제 #1
0
        public int DodajPost(string tytul, string tresc, int status, string tagi, string opis)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                Posty p = new Posty
                {
                    tytul = tytul,
                    tresc = tresc,
                    status = status,
                    data_dodania = DateTime.Now,
                    data_modyfikacji = DateTime.Now,
                };
                context.Posties.InsertOnSubmit(p);
                context.SubmitChanges();

                Tagi t = new Tagi
                {
                    id_posta = p.id,
                    keywords = tagi,
                    description = opis
                };

                context.Tagis.InsertOnSubmit(t);
                context.SubmitChanges();

                return p.id;
            }
        }
예제 #2
0
 public List <Models.PostTagModel> pobierzArchiwum(int year, int month)
 {
     using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
     {
         try
         {
             var lista = (from a in db.PostyTagis
                          where a.status != 0 && a.data_dodania.Year == year && a.data_dodania.Month == month
                          orderby a.data_dodania descending
                          select new Models.PostTagModel
             {
                 Tytul = a.tytul,
                 Tresc = a.tresc,
                 Status = a.status,
                 Keywords = a.keywords,
                 Id = a.id,
                 Desc = a.description,
                 DataModyfikacji = a.data_modyfikacji,
                 DataDodania = a.data_dodania,
             }).ToList();
             return(lista);
         }
         catch (Exception)
         {
             throw new Exception("Wystąpił błąd podczas pobierania wpisów");
         }
     }
 }
예제 #3
0
 public List <Models.PostTagModel> pobierzPorcjePoDacie(DateTime data)
 {
     using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
     {
         try
         {
             var lista = (from a in db.PostyTagis
                          where a.status != 0 && (a.data_dodania.Date == data.Date || (a.data_modyfikacji != null)? (((DateTime)a.data_modyfikacji).Date == data.Date):false)
                          orderby a.data_dodania descending
                          select new Models.PostTagModel
             {
                 Tytul = a.tytul,
                 Tresc = a.tresc,
                 Status = a.status,
                 Keywords = a.keywords,
                 Id = a.id,
                 Desc = a.description,
                 DataModyfikacji = a.data_modyfikacji,
                 DataDodania = a.data_dodania,
             }).ToList();
             return(lista);
         }
         catch (Exception)
         {
             throw new Exception("Wystąpił błąd podczas pobierania wpisów");
         }
     }
 }
예제 #4
0
 public List <Models.PostTagModel> pobierzZTagiem(string tag)
 {
     using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
     {
         try
         {
             var lista = (from a in db.PostyTagis
                          where a.status != 0 && a.keywords.ToLower().Contains(tag.ToLower())
                          orderby a.data_dodania descending
                          select new Models.PostTagModel
             {
                 Tytul = a.tytul,
                 Tresc = a.tresc,
                 Status = a.status,
                 Keywords = a.keywords,
                 Id = a.id,
                 Desc = a.description,
                 DataModyfikacji = a.data_modyfikacji,
                 DataDodania = a.data_dodania,
             }).ToList();
             return(lista);
         }
         catch (Exception)
         {
             throw new Exception("Wystąpił błąd podczas pobierania wpisów");
         }
     }
 }
예제 #5
0
        public int DodajPost(string tytul, string tresc, int status, string tagi, string opis)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                Posty p = new Posty
                {
                    tytul            = tytul,
                    tresc            = tresc,
                    status           = status,
                    data_dodania     = DateTime.Now,
                    data_modyfikacji = DateTime.Now,
                };
                context.Posties.InsertOnSubmit(p);
                context.SubmitChanges();

                Tagi t = new Tagi
                {
                    id_posta    = p.id,
                    keywords    = tagi,
                    description = opis
                };

                context.Tagis.InsertOnSubmit(t);
                context.SubmitChanges();

                return(p.id);
            }
        }
예제 #6
0
 public List <Models.PostTagModel> pobierzPorcje(int ile, int offset)
 {
     using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
     {
         try
         {
             var lista = (from a in db.PostyTagis
                          where a.status != 0
                          orderby a.data_dodania descending
                          select new Models.PostTagModel
             {
                 Tytul = a.tytul,
                 Tresc = a.tresc,
                 Status = a.status,
                 Keywords = a.keywords,
                 Id = a.id,
                 Desc = a.description,
                 DataModyfikacji = a.data_modyfikacji,
                 DataDodania = a.data_dodania,
             }).Skip(ile * offset).Take(ile).ToList();
             return(lista);
         }
         catch (Exception)
         {
             throw new Exception("Wystąpił błąd podczas pobierania wpisów");
         }
     }
 }
예제 #7
0
파일: TagDAL.cs 프로젝트: d3dek/AwesomeBlog
 public TagModel PobierzTagPosta(int id)
 {
     using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
     {
         try
         {
             var tagi = (from a in context.Tagis
                         where a.id_posta == id
                         select new TagModel
                         {
                             IdPosta = a.id_posta,
                             Desc = a.description,
                             Keywords = a.keywords
                         }).Single();
             //var tag = context.Tagis.Single(t => t.id_posta == id);
             //return new TagModel
             //      {
             //          IdPosta = tag.id_posta,
             //          Keywords = tag.keywords,
             //          Desc = tag.description
             //      };
             return tagi;
         }
         catch (InvalidOperationException)
         {
             return null;
         }
     }
 }
예제 #8
0
파일: TagDAL.cs 프로젝트: d3dek/AwesomeBlog
 public TagModel PobierzTagPosta(int id)
 {
     using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
     {
         try
         {
             var tagi = (from a in context.Tagis
                         where a.id_posta == id
                         select new TagModel
             {
                 IdPosta = a.id_posta,
                 Desc = a.description,
                 Keywords = a.keywords
             }).Single();
             //var tag = context.Tagis.Single(t => t.id_posta == id);
             //return new TagModel
             //      {
             //          IdPosta = tag.id_posta,
             //          Keywords = tag.keywords,
             //          Desc = tag.description
             //      };
             return(tagi);
         }
         catch (InvalidOperationException)
         {
             return(null);
         }
     }
 }
예제 #9
0
 public int PobierzIloscDlaID(int idPosta)
 {
     using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
     {
         var c = (from a in context.Komentarzes
                  where a.id_posta == idPosta
                  select a).Count();
         return(c);
     }
 }
예제 #10
0
 public int PobierzIloscDlaID(int idPosta)
 {
     using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
     {
         var c = (from a in context.Komentarzes
                  where a.id_posta == idPosta
                  select a).Count();
         return c;
     }
 }
예제 #11
0
파일: TagDAL.cs 프로젝트: d3dek/AwesomeBlog
        public void EdytujTag(int idPosta, string keywords)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                var tag = context.Tagis.Single(t => t.id_posta == idPosta);

                tag.keywords = keywords;

                context.SubmitChanges();
            }
        }
예제 #12
0
파일: TagDAL.cs 프로젝트: d3dek/AwesomeBlog
        public void EdytujTag(int idPosta, string keywords)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                var tag = context.Tagis.Single(t => t.id_posta == idPosta);

                tag.keywords = keywords;

                context.SubmitChanges();
            }
        }
예제 #13
0
 public string getSettings(string key)
 {
     using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
     {
         try
         {
             return (from k in db.Ustawienias where k.key == key select k.value).Single();
         }
         catch (Exception e)
         { throw new Exception(e.Message.ToString(), e); }
     }
 }
예제 #14
0
 public bool existSettings(string key)
 {
     using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
     {
         try
         {
             return((from k in db.Ustawienias where k.key == key select k).Any());
         }
         catch (Exception e)
         { throw new Exception(e.Message.ToString(), e); }
     }
 }
예제 #15
0
        public void UsunKomentarzeDlaPosta(int idPosta)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                var komentarze = from a in context.Komentarzes
                                 where a.id_posta == idPosta
                                 select a;

                context.Komentarzes.DeleteAllOnSubmit(komentarze);
                context.SubmitChanges();
            }
        }
예제 #16
0
        public void EdytujPost(int id, string tytul, string tresc, int status)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                var post = context.Posties.Single(p => p.id == id);
                post.tytul            = tytul;
                post.tresc            = tresc;
                post.status           = status;
                post.data_modyfikacji = DateTime.Now;

                context.SubmitChanges();
            }
        }
예제 #17
0
 public int ileWszystkichAktywnych()
 {
     using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
     {
         try
         {
             return((from a in db.Posties where a.status == 1 select a).Count());
         }
         catch (Exception)
         {
             throw new Exception("Wystąpił błąd podczas usuwania wpisu");
         }
     }
 }
예제 #18
0
파일: TagDAL.cs 프로젝트: d3dek/AwesomeBlog
 public void UsunTagiPostu(int idPosta)
 {
     using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
     {
         try
         {
             var lista = from a in db.Tagis where a.id_posta == idPosta select a;
             db.Tagis.DeleteAllOnSubmit(lista);
             db.SubmitChanges();
         }
         catch (Exception)
         { throw new Exception("Wystąpił błąd podczas usuwania tagów"); }
     }
 }
예제 #19
0
 public int ileWszystkichAktywnych()
 {
     using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
     {
         try
         {
             return (from a in db.Posties where a.status == 1 select a).Count();
         }
         catch (Exception)
         {
             throw new Exception("Wystąpił błąd podczas usuwania wpisu");
         }
     }
 }
예제 #20
0
파일: TagDAL.cs 프로젝트: d3dek/AwesomeBlog
        public void DodajTag(int idPosta, string keywords, string desc)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                Tagi t = new Tagi
                {
                    id_posta = idPosta,
                    keywords = keywords,
                    description = desc
                };

                context.Tagis.InsertOnSubmit(t);
                context.SubmitChanges();
            }
        }
예제 #21
0
파일: TagDAL.cs 프로젝트: d3dek/AwesomeBlog
        public List <TagModel> PobierzWszystkie()
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                var l = from a in context.Tagis
                        select new TagModel
                {
                    IdPosta  = a.id_posta,
                    Keywords = a.keywords,
                    Desc     = a.description
                };

                return(l.ToList());
            }
        }
예제 #22
0
파일: TagDAL.cs 프로젝트: d3dek/AwesomeBlog
        public void DodajTag(int idPosta, string keywords, string desc)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                Tagi t = new Tagi
                {
                    id_posta    = idPosta,
                    keywords    = keywords,
                    description = desc
                };

                context.Tagis.InsertOnSubmit(t);
                context.SubmitChanges();
            }
        }
예제 #23
0
 public PostModel PobierzPost(int id)
 {
     using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
     {
         var post = context.Posties.Single(p => p.id == id);
         return(new PostModel
         {
             Id = post.id,
             Tytul = post.tytul,
             Tresc = post.tresc,
             DataDodania = post.data_dodania,
             DataModyfikacji = post.data_modyfikacji,
             Status = post.status
         });
     }
 }
예제 #24
0
        public void DodajKomentarz(int idPosta, string autor, string tresc, int status)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                Komentarze k = new Komentarze
                {
                    id_posta     = idPosta,
                    autor        = autor,
                    tresc        = tresc,
                    status       = status,
                    data_dodania = DateTime.Now
                };

                context.Komentarzes.InsertOnSubmit(k);
                context.SubmitChanges();
            }
        }
예제 #25
0
        public void DodajKomentarz(int idPosta, string autor, string tresc, int status)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                Komentarze k = new Komentarze
                {
                   id_posta = idPosta,
                   autor = autor,
                   tresc = tresc,
                   status = status,
                   data_dodania = DateTime.Now
                };

                context.Komentarzes.InsertOnSubmit(k);
                context.SubmitChanges();
            }
        }
예제 #26
0
 public List <PostModel> PobierzWszystkie()
 {
     using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
     {
         var posty = from a in context.Posties
                     select new PostModel
         {
             Id              = a.id,
             DataDodania     = a.data_dodania,
             Tytul           = a.tytul,
             Tresc           = a.tresc,
             Status          = a.status,
             DataModyfikacji = a.data_modyfikacji.Value
         };
         List <PostModel> l = posty.ToList();
         return(l);
     }
 }
예제 #27
0
        public List <KomentarzModel> PobierzWszystkie()
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                var l = from a in context.Komentarzes
                        select new KomentarzModel
                {
                    Id          = a.id,
                    IdPosta     = a.id_posta,
                    Tresc       = a.tresc,
                    Autor       = a.autor,
                    DataDodania = a.data_dodania,
                    Status      = a.status
                };

                return(l.ToList());
            }
        }
예제 #28
0
        public void EdytujPost(int id, string tytul, string tresc, int status, string tagi, string opis)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                var post = context.Posties.Single(p => p.id == id);
                post.tytul            = tytul;
                post.tresc            = tresc;
                post.status           = status;
                post.data_modyfikacji = DateTime.Now;

                var tag = context.Tagis.Single(s => s.id_posta == id);

                tag.keywords    = tagi;
                tag.description = opis;

                context.SubmitChanges();
            }
        }
예제 #29
0
        public bool UsunKomentarz(int id)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                try
                {
                    Komentarze kom = context.Komentarzes.Single(k => k.id == id);

                    context.Komentarzes.DeleteOnSubmit(kom);
                    context.SubmitChanges();
                }
                catch (InvalidOperationException ex)
                {
                    return(false);
                }
                return(true);
            }
        }
예제 #30
0
        public List<KomentarzModel> PobierzWszystkie()
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                var l = from a in context.Komentarzes
                        select new KomentarzModel
                        {
                            Id = a.id,
                            IdPosta = a.id_posta,
                            Tresc = a.tresc,
                            Autor = a.autor,
                            DataDodania = a.data_dodania,
                            Status = a.status
                        };

                return l.ToList();
            }
        }
예제 #31
0
 public List<Models.ArchiveModel> GetArchive()
 {
     using(LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
     {
         try
         {
             var archive = from a in db.Archiwums
                           select new Models.ArchiveModel
                           {
                               count=(a.ilosc==null)?0:(int)a.ilosc,
                               month=(a.miesiac==null)?0:(int)a.miesiac,
                               year=(a.rok==null)?0:(int)a.rok
                           };
             return archive.ToList();
         }
         catch(Exception)
         { throw new Exception("Wystąpił błąd podczas tworzenia listy archiwum");}
     }
 }
예제 #32
0
        public int DodajPost(string tytul, string tresc, int status)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                Posty p = new Posty
                {
                    tytul = tytul,
                    tresc = tresc,
                    status = status,
                    data_dodania = DateTime.Now,
                    data_modyfikacji = DateTime.Now //dodanie postu to jednocześnie ostatnia modyfikacja
                };

                context.Posties.InsertOnSubmit(p);
                context.SubmitChanges();

                return p.id;
            }
        }
예제 #33
0
        public int DodajPost(string tytul, string tresc, int status)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                Posty p = new Posty
                {
                    tytul            = tytul,
                    tresc            = tresc,
                    status           = status,
                    data_dodania     = DateTime.Now,
                    data_modyfikacji = DateTime.Now //dodanie postu to jednocześnie ostatnia modyfikacja
                };

                context.Posties.InsertOnSubmit(p);
                context.SubmitChanges();

                return(p.id);
            }
        }
예제 #34
0
 public List <Models.ArchiveModel> GetArchive()
 {
     using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
     {
         try
         {
             var archive = from a in db.Archiwums
                           select new Models.ArchiveModel
             {
                 count = (a.ilosc == null)?0:(int)a.ilosc,
                 month = (a.miesiac == null)?0:(int)a.miesiac,
                 year  = (a.rok == null)?0:(int)a.rok
             };
             return(archive.ToList());
         }
         catch (Exception)
         { throw new Exception("Wystąpił błąd podczas tworzenia listy archiwum"); }
     }
 }
예제 #35
0
        public bool usunPost(int id)
        {
            using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
            {
                try
                {
                    new KomentarzDAL().UsunKomentarzeDlaPosta(id);
                    new TagDAL().UsunTagiPostu(id);

                    var post = (from a in db.Posties where a.id == id select a).Single();
                    db.Posties.DeleteOnSubmit(post);
                    db.SubmitChanges();
                    return(true);
                }
                catch (Exception)
                {
                    throw new Exception("Wystąpił błąd podczas usuwania wpisu");
                }
            }
        }
예제 #36
0
        public int dodajPost(Models.PostTagModel model)
        {
            using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
            {
                try
                {
                    Posty p = new Posty
                    {
                        tytul = model.Tytul,
                        tresc = model.Tresc,
                        data_dodania = DateTime.Now,
                        data_modyfikacji = DateTime.Now,
                        status = model.Status
                    };

                    db.Posties.InsertOnSubmit(p);
                    db.SubmitChanges();

                    Tagi t = new Tagi
                    {
                        description = model.Desc,
                        keywords = model.Keywords,
                        id_posta = p.id
                    };

                    db.Tagis.InsertOnSubmit(t);
                    db.SubmitChanges();

                    return p.id;
                }
                catch (Exception)
                {
                    return 0;
                    /*throw new Exception("Wystąpił błąd podczas dodawania nowego postu");*/
                }
            }
        }
예제 #37
0
        public int dodajPost(Models.PostTagModel model)
        {
            using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
            {
                try
                {
                    Posty p = new Posty
                    {
                        tytul            = model.Tytul,
                        tresc            = model.Tresc,
                        data_dodania     = DateTime.Now,
                        data_modyfikacji = DateTime.Now,
                        status           = model.Status
                    };

                    db.Posties.InsertOnSubmit(p);
                    db.SubmitChanges();

                    Tagi t = new Tagi
                    {
                        description = model.Desc,
                        keywords    = model.Keywords,
                        id_posta    = p.id
                    };

                    db.Tagis.InsertOnSubmit(t);
                    db.SubmitChanges();

                    return(p.id);
                }
                catch (Exception)
                {
                    return(0);
                    /*throw new Exception("Wystąpił błąd podczas dodawania nowego postu");*/
                }
            }
        }
예제 #38
0
        public void UsunKomentarzeDlaPosta(int idPosta)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                var komentarze = from a in context.Komentarzes
                                 where a.id_posta == idPosta
                                 select a;

                context.Komentarzes.DeleteAllOnSubmit(komentarze);
                context.SubmitChanges();
            }
        }
예제 #39
0
        public bool UsunKomentarz(int id)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                try
                {
                    Komentarze kom = context.Komentarzes.Single(k => k.id == id);

                    context.Komentarzes.DeleteOnSubmit(kom);
                    context.SubmitChanges();
                }
                catch (InvalidOperationException ex)
                {
                    return false;
                }
                return true;
            }
        }
예제 #40
0
 public List<Models.PostTagModel> pobierzPorcjePoDacie(DateTime data)
 {
     using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
     {
         try
         {
             var lista = (from a in db.PostyTagis
                          where a.status != 0 && (a.data_dodania.Date == data.Date || (a.data_modyfikacji!=null)? (((DateTime)a.data_modyfikacji).Date == data.Date):false)
                          orderby a.data_dodania descending
                          select new Models.PostTagModel
                          {
                              Tytul = a.tytul,
                              Tresc = a.tresc,
                              Status = a.status,
                              Keywords = a.keywords,
                              Id = a.id,
                              Desc = a.description,
                              DataModyfikacji = a.data_modyfikacji,
                              DataDodania = a.data_dodania,
                          }).ToList();
             return lista;
         }
         catch (Exception)
         {
             throw new Exception("Wystąpił błąd podczas pobierania wpisów");
         }
     }
 }
예제 #41
0
 public List<Models.PostTagModel> pobierzPorcje(int ile, int offset)
 {
     using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
     {
         try
         {
             var lista = (from a in db.PostyTagis
                          where a.status != 0
                          orderby a.data_dodania descending
                          select new Models.PostTagModel
                          {
                              Tytul = a.tytul,
                              Tresc = a.tresc,
                              Status = a.status,
                              Keywords = a.keywords,
                              Id = a.id,
                              Desc = a.description,
                              DataModyfikacji = a.data_modyfikacji,
                              DataDodania = a.data_dodania,
                          }).Skip(ile * offset).Take(ile).ToList();
             return lista;
         }
         catch (Exception)
         {
             throw new Exception("Wystąpił błąd podczas pobierania wpisów");
         }
     }
 }
예제 #42
0
 public List<Models.PostTagModel> pobierzZTagiem(string tag)
 {
     using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
     {
         try
         {
             var lista = (from a in db.PostyTagis
                          where a.status != 0 && a.keywords.ToLower().Contains(tag.ToLower())
                          orderby a.data_dodania descending
                          select new Models.PostTagModel
                          {
                              Tytul = a.tytul,
                              Tresc = a.tresc,
                              Status = a.status,
                              Keywords = a.keywords,
                              Id = a.id,
                              Desc = a.description,
                              DataModyfikacji = a.data_modyfikacji,
                              DataDodania = a.data_dodania,
                          }).ToList();
             return lista;
         }
         catch (Exception)
         {
             throw new Exception("Wystąpił błąd podczas pobierania wpisów");
         }
     }
 }
예제 #43
0
파일: TagDAL.cs 프로젝트: d3dek/AwesomeBlog
        public List<TagModel> PobierzWszystkie()
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                var l = from a in context.Tagis
                        select new TagModel
                        {
                            IdPosta = a.id_posta,
                            Keywords = a.keywords,
                            Desc = a.description
                        };

                return l.ToList();
            }
        }
예제 #44
0
 public List<Models.PostTagModel> pobierzArchiwum(int year, int month)
 {
     using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
     {
         try
         {
             var lista = (from a in db.PostyTagis
                          where a.status != 0 && a.data_dodania.Year == year && a.data_dodania.Month == month
                          orderby a.data_dodania descending
                          select new Models.PostTagModel
                          {
                              Tytul = a.tytul,
                              Tresc = a.tresc,
                              Status = a.status,
                              Keywords = a.keywords,
                              Id = a.id,
                              Desc = a.description,
                              DataModyfikacji = a.data_modyfikacji,
                              DataDodania = a.data_dodania,
                          }).ToList();
             return lista;
         }
         catch (Exception)
         {
             throw new Exception("Wystąpił błąd podczas pobierania wpisów");
         }
     }
 }
예제 #45
0
        public bool usunPost(int id)
        {
            using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
            {
                try
                {
                    new KomentarzDAL().UsunKomentarzeDlaPosta(id);
                    new TagDAL().UsunTagiPostu(id);

                    var post = (from a in db.Posties where a.id == id select a).Single();
                    db.Posties.DeleteOnSubmit(post);
                    db.SubmitChanges();
                    return true;
                }
                catch (Exception)
                {
                    throw new Exception("Wystąpił błąd podczas usuwania wpisu");
                }
            }
        }
예제 #46
0
파일: TagDAL.cs 프로젝트: d3dek/AwesomeBlog
 public void UsunTagiPostu(int idPosta)
 {
     using (LinqTodbBlogDataContext db = new LinqTodbBlogDataContext())
     {
         try
         {
             var lista = from a in db.Tagis where a.id_posta == idPosta select a;
             db.Tagis.DeleteAllOnSubmit(lista);
             db.SubmitChanges();
         }
         catch (Exception)
         { throw new Exception("Wystąpił błąd podczas usuwania tagów"); }
     }
 }
예제 #47
0
        public void EdytujPost(int id, string tytul, string tresc, int status)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                var post = context.Posties.Single(p => p.id == id);
                post.tytul = tytul;
                post.tresc = tresc;
                post.status = status;
                post.data_modyfikacji = DateTime.Now;

                context.SubmitChanges();
            }
        }
예제 #48
0
 public List<PostModel> PobierzWszystkie()
 {
     using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
     {
         var posty = from a in context.Posties
                     select new PostModel
                     {
                         Id = a.id,
                         DataDodania = a.data_dodania,
                         Tytul = a.tytul,
                         Tresc = a.tresc,
                         Status = a.status,
                         DataModyfikacji = a.data_modyfikacji.Value
                     };
         List<PostModel> l = posty.ToList();
         return l;
     }
 }
예제 #49
0
 public PostModel PobierzPost(int id)
 {
     using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
     {
         var post = context.Posties.Single(p => p.id == id);
                    return new PostModel
                    {
                        Id = post.id,
                        Tytul = post.tytul,
                        Tresc = post.tresc,
                        DataDodania = post.data_dodania,
                        DataModyfikacji = post.data_modyfikacji,
                        Status = post.status
                    };
     }
 }
예제 #50
0
        public void EdytujPost(int id, string tytul, string tresc, int status, string tagi, string opis)
        {
            using (LinqTodbBlogDataContext context = new LinqTodbBlogDataContext())
            {
                var post = context.Posties.Single(p => p.id == id);
                post.tytul = tytul;
                post.tresc = tresc;
                post.status = status;
                post.data_modyfikacji = DateTime.Now;

                var tag = context.Tagis.Single(s => s.id_posta == id);

                tag.keywords = tagi;
                tag.description = opis;

                context.SubmitChanges();
            }
        }