//funkcja dodawania posta public bool DodajPosta(PostNew new_post) { try { Post post = new Post(); post.data_dodania = new_post.data_dodania; post.data_modyfikacji = new_post.data_modyfikacji; post.status = 0; post.tresc = new_post.tresc; post.tytul = new_post.tytul; db.Posts.InsertOnSubmit(post); db.SubmitChanges(); Tagi tag = new Tagi(); tag.id_post = post.id; tag.description = new_post.description; tag.keywords = new_post.keywords; db.Tagis.InsertOnSubmit(tag); db.SubmitChanges(); return(true); } catch { return(false); } }
//funkcja dodawania posta public bool DodajPosta(PostNew new_post) { try { Post post = new Post(); post.data_dodania = new_post.data_dodania; post.data_modyfikacji = new_post.data_modyfikacji; post.status = 0; post.tresc = new_post.tresc; post.tytul = new_post.tytul; db.Posts.InsertOnSubmit(post); db.SubmitChanges(); Tagi tag = new Tagi(); tag.id_post = post.id; tag.description = new_post.description; tag.keywords = new_post.keywords; db.Tagis.InsertOnSubmit(tag); db.SubmitChanges(); return true; } catch { return false; } }
/// <summary> /// Create a new Tagi object. /// </summary> /// <param name="id_posta">Initial value of the id_posta property.</param> /// <param name="keywords">Initial value of the keywords property.</param> /// <param name="description">Initial value of the description property.</param> /// <param name="id">Initial value of the id property.</param> public static Tagi CreateTagi(global::System.Int32 id_posta, global::System.String keywords, global::System.String description, global::System.Int32 id) { Tagi tagi = new Tagi(); tagi.id_posta = id_posta; tagi.keywords = keywords; tagi.description = description; tagi.id = id; return(tagi); }
public bool UsunPosta(int id) { try { Tagi deleteTag = null; do { try { deleteTag = UsunDoTagi(id); db.Tagis.DeleteOnSubmit(deleteTag); db.SubmitChanges(); } catch { deleteTag = null; } } while (deleteTag != null); Komentarze deleteKomentarz = null; do { try { deleteKomentarz = UsunDoKomentarze(id); db.Komentarzes.DeleteOnSubmit(deleteKomentarz); db.SubmitChanges(); } catch { deleteKomentarz = null; } } while (deleteKomentarz != null); Post deletePost = UsunDoPost(id); db.Posts.DeleteOnSubmit(deletePost); db.SubmitChanges(); return(true); } catch { return(false); } }
public ActionResult DodajPost(Post collection) { if (ModelState.IsValid) { DateTime now=DateTime.Now; now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second); collection.data_dodania = now; blogDB.AddToPost(collection); blogDB.SaveChanges(); int post_id = blogDB.Post.Single(p => p.data_dodania == collection.data_dodania).id; Tagi tag = new Tagi(); tag.id_posta = post_id; return View("Tagi",tag); } else { ViewData["list"] = lista(); return View(collection); } }
/// <summary> /// Deprecated Method for adding a new object to the Tagi EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToTagi(Tagi tagi) { base.AddObject("Tagi", tagi); }
/// <summary> /// Create a new Tagi object. /// </summary> /// <param name="id_posta">Initial value of the id_posta property.</param> /// <param name="keywords">Initial value of the keywords property.</param> /// <param name="description">Initial value of the description property.</param> /// <param name="id">Initial value of the id property.</param> public static Tagi CreateTagi(global::System.Int32 id_posta, global::System.String keywords, global::System.String description, global::System.Int32 id) { Tagi tagi = new Tagi(); tagi.id_posta = id_posta; tagi.keywords = keywords; tagi.description = description; tagi.id = id; return tagi; }
partial void DeleteTagi(Tagi instance);
partial void UpdateTagi(Tagi instance);
partial void InsertTagi(Tagi instance);
public ActionResult Tagi(Tagi collection) { if (ModelState.IsValid) { blogDB.AddToTagi(collection); blogDB.SaveChanges(); return RedirectToAction("Index"); } else { return RedirectToAction("DodajPost"); } }
public Tagi UsunDoTagi(int id) { Tagi deleteTag = (from m in db.Tagis where m.id_post == id select m).First(); return(deleteTag); }