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); } }
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(); } }
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");*/ } } }
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");*/ } } }
partial void DeleteTagi(Tagi instance);
partial void UpdateTagi(Tagi instance);
partial void InsertTagi(Tagi instance);