Пример #1
0
 protected void btn_SaveKomentar_Click(object sender, EventArgs e)
 {
     if (txt_Sadrzaj.Text == String.Empty)
     {
         return;
     }
     else
     {
         Data.EntityFramework.DAL.Korisnik korisnik = (Data.EntityFramework.DAL.Korisnik)Session["LogiraniKorisnik"];
         if (korisnik == null)
         {
             Response.Redirect("/Login.aspx?ReturnUrl=" + Request.Url);
         }
         else
         {
             if (PostId != 0)
             {
                 using (TriglavBL temp = new TriglavBL())
                 {
                     Data.EntityFramework.DAL.Komentari komentar = new Data.EntityFramework.DAL.Komentari();
                     komentar.Sadrzaj = txt_Sadrzaj.Text;
                     komentar.DatumKreiranja = DateTime.Now;
                     komentar.Likes = 0;
                     komentar.Unlikes = 0;
                     komentar.PostID = PostId;
                     komentar.KorisnikID = korisnik.id;
                     komentar.isRazgovor = 0;
                     temp.SaveKomentar(komentar);
                     Data.EntityFramework.DAL.Post post = temp.getPostByID(PostId);
                     post.BrojKomentara++;
                     temp.UpdatePost(post);
                     ResetirajPolja();
                 }
             }
         }
     }
 }
Пример #2
0
 protected void btn_SaveKomentar_Click(object sender, EventArgs e)
 {
     if (txt_Sadrzaj.Text == String.Empty)
     {
         return;
     }
     else
     {
         Data.EntityFramework.DAL.Korisnik korisnik = (Data.EntityFramework.DAL.Korisnik)Session["LogiraniKorisnik"];
         if (korisnik == null)
         {
             Response.Redirect("/Login.aspx?ReturnUrl=" + Request.Url);
         }
         else
         {
             if (PostId != 0)
             {
                 using (TriglavBL temp = new TriglavBL())
                 {
                     Data.EntityFramework.DAL.Komentari komentar = new Data.EntityFramework.DAL.Komentari();
                     komentar.Sadrzaj        = txt_Sadrzaj.Text;
                     komentar.DatumKreiranja = DateTime.Now;
                     komentar.Likes          = 0;
                     komentar.Unlikes        = 0;
                     komentar.PostID         = PostId;
                     komentar.KorisnikID     = korisnik.id;
                     komentar.isRazgovor     = 0;
                     temp.SaveKomentar(komentar);
                     Data.EntityFramework.DAL.Post post = temp.getPostByID(PostId);
                     post.BrojKomentara++;
                     temp.UpdatePost(post);
                     ResetirajPolja();
                 }
             }
         }
     }
 }