public ActionResult Create(int id)
        {
            Komentarze komentarze = new Komentarze();

            komentarze.id_produktu = id;
            return(View(komentarze));
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Komentarze komentarze = db.Komentarzes.Find(id);

            db.Komentarzes.Remove(komentarze);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
        public ActionResult DodajKom()
        {
            Komentarze kom = new Komentarze();

            ViewData["list"] = lista();

            return(PartialView(kom));
        }
예제 #4
0
 public ActionResult Edit([Bind(Include = "KomentarzeId,Tresc,DataPublikacji,Ip,Uzytkownik,Nick,CzyOpublikowany,PostyId")] Komentarze komentarze)
 {
     if (ModelState.IsValid)
     {
         db.Entry(komentarze).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PostyId = new SelectList(db.Posts, "PostyId", "Tytul", komentarze.PostyId);
     return(View(komentarze));
 }
예제 #5
0
        public void DodajKomTest()
        {
            AdministracjaController target = new AdministracjaController(); // TODO: Initialize to an appropriate value
            Komentarze   nkom     = null;                                   // TODO: Initialize to an appropriate value
            ActionResult expected = null;                                   // TODO: Initialize to an appropriate value
            ActionResult actual;

            actual = target.DodajKom(nkom);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
        public async Task <ActionResult> Delete(int id = 0)
        {
            Komentarze komentarze = await db.Komentarze.FindAsync(id);

            if ((!User.IsInRole("ban")) && (!User.IsInRole("normal")) && (!(User.Identity.Name != komentarze.e_mail)))
            {
                db.Komentarze.Remove(komentarze);
                await db.SaveChangesAsync();
            }
            return(RedirectToAction("Index", "Home"));
        }
예제 #7
0
 public ActionResult DodajKomentarz(int id, Komentarze new_komentarz)
 {
     if (db_admin.DodajKomentarz(id, new_komentarz))
     {
         ViewData["action"] = "Komentarz zostal dodany ;)";
     }
     else
     {
         ViewData["action"] = "Komentarz nie zostal dodany ;(";
     }
     return(View(new_komentarz));
 }
예제 #8
0
 public ActionResult UsunKomentarz(int id, Komentarze komentarz)
 {
     //<input type="text" value="<%=Model.id.ToString() %>" readonly = "readonly" />
     if (db_admin.UsunKomentarz(id))
     {
         ViewData["action"] = "Komentarz zostal usuniety ;)";
     }
     else
     {
         ViewData["action"] = "Komentarz nie zostal usuniety ;(";
     }
     return(View(komentarz));
 }
예제 #9
0
        // GET: Komentarze/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Komentarze komentarze = db.Komentarzes.Find(id);

            if (komentarze == null)
            {
                return(HttpNotFound());
            }
            return(View(komentarze));
        }
예제 #10
0
        public ActionResult UsunKom(int id)
        {
            Komentarze dkom = blogDB.Komentarze.Single(dk => dk.id == id);

            blogDB.Komentarze.DeleteObject(dkom);
            blogDB.SaveChanges();


            var kom = from komentarze in blogDB.Komentarze
                      where komentarze.Post.id == dkom.id_posta
                      orderby komentarze.data_dodania descending
                      select komentarze;

            return(PartialView("WysKomentarze", kom));
        }
예제 #11
0
        // GET: Komentarze/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Komentarze komentarze = db.Komentarzes.Find(id);

            if (komentarze == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PostyId = new SelectList(db.Posts, "PostyId", "Tytul", komentarze.PostyId);
            return(View(komentarze));
        }
예제 #12
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();
            }
        }
예제 #13
0
        public ActionResult DodajKom(Komentarze nkom)
        {
            if (ModelState.IsValid)
            {
                nkom.id_posta     = nkom.id;//??
                nkom.id           = 0;
                nkom.data_dodania = DateTime.Now;

                blogDB.AddToKomentarze(nkom);
                blogDB.SaveChanges();

                return(View());
            }
            else
            {
                return(View(nkom));
            }
        }
예제 #14
0
 public ActionResult dodajKomentarz(int id, Komentarze k)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _komentarz.DodajKomentarz(id,k);
             //ViewData["alert"] = "dodany";
             return RedirectToAction("wyswietlKomentarze/"+id.ToString(), "Home");
         }
         else
             return View();
     }
     catch
     {
         return RedirectToAction("Error", "Shared");
     }
 }
예제 #15
0
        public ActionResult DodajKomentarz(FormCollection formCollection)
        {
            if (formCollection["Nick"] != "" && formCollection["Wiadomosc"] != "")
            {
                Komentarze nowyKomentarz = new Komentarze();
                nowyKomentarz.Nick           = formCollection["Nick"];
                nowyKomentarz.Tresc          = formCollection["Wiadomosc"];
                nowyKomentarz.DataPublikacji = DateTime.Now;
                nowyKomentarz.PostyId        = Convert.ToInt32(formCollection["PostyId"]);

                db.Komentarzes.Add(nowyKomentarz);
                db.SaveChanges();

                ViewBag.Error = string.Empty;
                return(View("Szczegoly", db.Posts.Find(Convert.ToInt32(formCollection["PostyId"]))));
            }

            ViewBag.Error = "Wprowadź poprawnie dane";
            return(View("Szczegoly", db.Posts.Find(Convert.ToInt32(formCollection["PostyId"]))));
        }
예제 #16
0
 public ActionResult dodajKomentarz(int id, Komentarze k)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _komentarz.DodajKomentarz(id, k);
             //ViewData["alert"] = "dodany";
             return(RedirectToAction("wyswietlKomentarze/" + id.ToString(), "Home"));
         }
         else
         {
             return(View());
         }
     }
     catch
     {
         return(RedirectToAction("Error", "Shared"));
     }
 }
        public async Task <ActionResult> Createaut(Komentarze komentarze)
        {
            if (ModelState.IsValid)
            {
                komentarze.data_dodania = DateTime.Now;
                komentarze.e_mail       = User.Identity.Name;
                List <Klienci> hy = db.Klienci.ToList();
                for (int i = 0; i < hy.Count(); i++)
                {
                    if (User.Identity.Name == hy[i].email)
                    {
                        komentarze.id_uzytkownika = hy[i].Id_uzytkownik;
                    }
                }

                db.Komentarze.Add(komentarze);
                await db.SaveChangesAsync();
            }

            return(RedirectToAction("Index", "Home"));
        }
예제 #18
0
        public ActionResult DodajKom()
        {
            Komentarze kom = new Komentarze();

            return(PartialView(kom));
        }