예제 #1
0
        [HttpPost]//dodaj tagi
        public ActionResult Tagi(Tagi collection)
        {
            if (ModelState.IsValid)
            {
                blogDB.AddToTagi(collection);
                blogDB.SaveChanges();
                return(RedirectToAction("Index"));
            }

            else
            {
                return(RedirectToAction("DodajPost"));
            }
        }
예제 #2
0
 public ActionResult Dodaj(PostTag nowy_post)
 {
     try
     {
         nowy_post.post.status       = 0;
         nowy_post.post.data_dodania = DateTime.Now;
         blogDB.AddToPost(nowy_post.post);
         blogDB.SaveChanges();
         var post = blogDB.Post.Single(a => a.tresc == nowy_post.post.tresc);
         //var post = blogDB.Post.Single(a => a.data_dodania.Equals(nowy_post.post.data_dodania));
         nowy_post.tag.id_posta = post.id;
         blogDB.AddToTagi(nowy_post.tag);//pobrać id
         blogDB.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(nowy_post));
     }
 }