Inheritance: System.Data.Linq.DataContext
Exemple #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;
            }
        }
Exemple #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");
         }
     }
 }
Exemple #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");
         }
     }
 }
Exemple #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");
         }
     }
 }
Exemple #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);
            }
        }
Exemple #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");
         }
     }
 }
Exemple #7
0
 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;
         }
     }
 }
Exemple #8
0
 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);
         }
     }
 }
Exemple #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);
     }
 }
Exemple #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;
     }
 }
Exemple #11
0
        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();
            }
        }
Exemple #12
0
        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();
            }
        }
Exemple #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); }
     }
 }
Exemple #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); }
     }
 }
Exemple #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();
            }
        }
Exemple #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();
            }
        }
Exemple #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");
         }
     }
 }
Exemple #18
0
 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"); }
     }
 }
Exemple #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");
         }
     }
 }
Exemple #20
0
        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();
            }
        }
Exemple #21
0
        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());
            }
        }
Exemple #22
0
        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();
            }
        }
Exemple #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
         });
     }
 }
Exemple #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();
            }
        }
Exemple #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();
            }
        }
Exemple #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);
     }
 }
Exemple #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());
            }
        }
Exemple #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();
            }
        }
Exemple #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);
            }
        }
Exemple #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();
            }
        }
Exemple #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");}
     }
 }
Exemple #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;
            }
        }
Exemple #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);
            }
        }
Exemple #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"); }
     }
 }
Exemple #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");
                }
            }
        }
Exemple #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");*/
                }
            }
        }
Exemple #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");*/
                }
            }
        }
Exemple #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();
            }
        }
Exemple #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;
            }
        }
Exemple #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");
         }
     }
 }
Exemple #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");
         }
     }
 }
Exemple #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");
         }
     }
 }
Exemple #43
0
        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();
            }
        }
Exemple #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");
         }
     }
 }
Exemple #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");
                }
            }
        }
Exemple #46
0
 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"); }
     }
 }
Exemple #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();
            }
        }
Exemple #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;
     }
 }
Exemple #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
                    };
     }
 }
Exemple #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();
            }
        }