Ejemplo n.º 1
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));
     }
 }
Ejemplo n.º 2
0
        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));
            }
        }