コード例 #1
0
        protected void btn_Like_Click(object sender, ImageClickEventArgs e)
        {
            using (TriglavBL temp = new TriglavBL())
            {
                user_likes = temp.getUserLikes(korisnik.id, post.id);

                if (user_likes == null)
                {
                    user_likes = new Data.EntityFramework.DAL.User_Likes();
                    user_likes.PostId = post.id;
                    user_likes.UserId = korisnik.id;
                    user_likes.DaumRated = DateTime.Now;
                    user_likes.DatumLajkanja = DateTime.Now;
                    user_likes.isLiked = 1;
                    user_likes.Rate = 0;
                    temp.SaveUser_Likes(user_likes);
                }
                else
                {
                    Int32 LikesBefore = temp.getVoteUserLikes(user_likes.UserId.Value, user_likes.PostId.Value);
                    user_likes.DatumLajkanja = DateTime.Now;
                    user_likes.isLiked = 1;
                    temp.UpdateUser_Likes(user_likes, LikesBefore);
                }
            }
            LoadClanak(post.id);
        }
コード例 #2
0
        protected void btn_oLike_Click(object sender, ImageClickEventArgs e)
        {
            if (korisnik != null)
            {

                ImageButton _sender = (ImageButton)sender;
                HiddenField hid = (HiddenField)_sender.FindControl("hf");

                using (TriglavBL temp = new TriglavBL())
                {
                    Post odgovorNaLIsti = temp.getOdgovorByID(Convert.ToInt32(hid.Value));

                    if (odgovorNaLIsti != null)
                    {
                        user_likes = temp.getUserLikes(korisnik.id, odgovorNaLIsti.id);

                        if (user_likes == null)
                        {
                            user_likes = new Data.EntityFramework.DAL.User_Likes();
                            user_likes.PostId = odgovorNaLIsti.id;
                            user_likes.UserId = korisnik.id;
                            user_likes.DaumRated = DateTime.Now;
                            user_likes.DatumLajkanja = DateTime.Now;
                            user_likes.isLiked = 1;
                            user_likes.Rate = 0;
                            temp.SaveUser_Likes(user_likes);
                        }
                        else
                        {
                            Int32 LikesBefore = temp.getVoteUserLikes(user_likes.UserId.Value, user_likes.PostId.Value);
                            user_likes.DatumLajkanja = DateTime.Now;
                            user_likes.isLiked = 1;
                            temp.UpdateUser_Likes(user_likes, LikesBefore);
                        }
                    }
                }
                LoadClanak(post.id);
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "Login()", true);
            }
        }
コード例 #3
0
        private void RateThis(int rate)
        {
            using (TriglavBL temp = new TriglavBL())
            {
                user_likes = temp.getUserLikes(korisnik.id, post.id);

                if (user_likes == null) //ako ne postoji zapis
                {
                    user_likes = new Data.EntityFramework.DAL.User_Likes();
                    user_likes.PostId = post.id;
                    user_likes.UserId = korisnik.id;
                    user_likes.DatumLajkanja = DateTime.Now;
                    user_likes.DaumRated = DateTime.Now;
                    user_likes.isLiked = 0;
                    user_likes.Rate = rate; // setujemo rate
                    temp.SaveUser_Likes_Rates(user_likes);
                }
                else
                {
                    Int32 RateBefore = temp.getRateUserLikes(user_likes.UserId.Value, user_likes.PostId.Value);
                    user_likes.DatumLajkanja = DateTime.Now;
                    user_likes.DaumRated = DateTime.Now;
                    user_likes.Rate = rate;
                    temp.UpdateUser_Likes_Rates(user_likes, RateBefore);
                }
            }
            LoadClanak(post.id);
        }
コード例 #4
0
        /// <summary>
        /// USER VOTES POSTS/////////////////////////////////////////////////////////////////////////////
        /// </summary>
        /// 
        private void GetVotesInfo()
        {
            using (TriglavBL temp = new TriglavBL())
            {
                if (korisnik != null)
                {
                    user_likes = temp.getUserLikes(korisnik.id, post.id);
                    if (user_likes != null)
                    {
                        if (user_likes.isLiked == 0)
                        {
                            lbl_Likes.Text = Convert.ToString(post.Likes.Value) + " osoba je glasovalo za! ";
                            lbl_Unlikes.Text = Convert.ToString(post.Unlikes.Value) + " osoba je glasovalo protiv! ";
                            btn_Like.Enabled = true;
                            btn_Unlike.Enabled = true;
                        }
                        if (user_likes.isLiked == 1)
                        {
                            lbl_Likes.Text = "Vi i još " + Convert.ToString(post.Likes.Value - 1) + " osoba je glasovalo za! ";
                            lbl_Unlikes.Text = Convert.ToString(post.Unlikes.Value) + " osoba je glasovalo protiv! ";
                            btn_Like.Enabled = false;
                            btn_Unlike.Enabled = true;
                        }
                        if (user_likes.isLiked == 2)
                        {
                            lbl_Likes.Text = Convert.ToString(post.Likes.Value) + " osoba je glasovalo za! ";
                            lbl_Unlikes.Text = "Vi i još " + Convert.ToString(post.Unlikes.Value - 1) + " osoba ste glasovali protiv! ";
                            btn_Like.Enabled = true;
                            btn_Unlike.Enabled = false;
                        }
                    }
                    else
                    {
                        lbl_Likes.Text = Convert.ToString(post.Likes.Value) + " osoba je glasovalo za! ";
                        lbl_Unlikes.Text = Convert.ToString(post.Unlikes.Value) + " osoba je glasovalo protiv! ";
                        btn_Like.Enabled = true; // btn vote up
                        btn_Unlike.Enabled = true; // btn vote down
                    }

                }
                else
                {
                    lbl_Likes.Text = Convert.ToString(post.Likes.Value) + " osoba je glasovalo za! ";
                    lbl_Unlikes.Text = Convert.ToString(post.Unlikes.Value) + " osoba je glasovalo protiv! ";
                    btn_Like.Enabled = false; // btn vote up
                    btn_Unlike.Enabled = false; // btn vote down
                }
            }
        }
コード例 #5
0
 /// <summary>
 /// USER RATES POSTS/////////////////////////////////////////////////////////////////////////////
 /// </summary>
 /// 
 private void GetRatesInfo()
 {
     using (TriglavBL temp = new TriglavBL())
     {
         if (korisnik != null)
         {
             if (temp.getUserLikes(korisnik.id, post.id) == null) //zapis u bazi ne postoji
             {
                 EnableAllRateButtons();
             }
             else //zapis u bazi postoji
             {
                 if (temp.getRateUserLikes(korisnik.id, post.id) == 0)
                 {
                     EnableAllRateButtons();
                 }
                 else
                 {
                     int userRate = temp.getRateUserLikes(korisnik.id, post.id);
                     SwitchRateButton(userRate);
                 }
             }
         }
         else
         {
             DisableAllRateButtons();
         }
     }
     if (post.BrojRangiranja > 0)
         lbl_Rejting.Text = Convert.ToString(post.BrojOmiljenih.Value / post.BrojRangiranja.Value);
     else
         lbl_Rejting.Text = Convert.ToString(0);
 }
コード例 #6
0
        protected void dl_odgovori_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            int id = (int)DataBinder.Eval(e.Item.DataItem, "id");

            using (TriglavBL temp = new TriglavBL())
            {
                Post p = temp.getPostByID(id);
                Data.EntityFramework.DAL.Korisnik k = temp.getKorisnikByID(p.VlasnikID.Value);
                System.Web.UI.WebControls.ImageButton img_User = (System.Web.UI.WebControls.ImageButton)e.Item.FindControl("img_User");
                img_User.ImageUrl = k.SlikaURL;
                img_User.PostBackUrl = "/Public/QA_Pitanja.aspx?KorisnikID=" + p.VlasnikID.Value;

                Label reputacija = (Label)e.Item.FindControl("lbl_Reputacija");
                reputacija.Text = "Reputacija: " + k.Reputacija;

                System.Web.UI.WebControls.ImageButton img_Bedz = (System.Web.UI.WebControls.ImageButton)e.Item.FindControl("img_Bedz");
                img_Bedz.ImageUrl = k.BedzSlika;
                img_Bedz.PostBackUrl = "/Public/QA_Bedz.aspx?BedzID=" + k.BedzID.Value;

                Label lbl_NazivBedza = (Label)e.Item.FindControl("lbl_NazivBedza");
                lbl_NazivBedza.Text = k.BedzNaziv;
                lbl_NazivBedza.ToolTip = k.BedzOpis;

                Label lbl_BrojPoena = (Label)e.Item.FindControl("lbl_BrojPoena");
                lbl_BrojPoena.Text = Convert.ToString(p.BrojPoena);

                if (p.BrojPoena >= 3)
                {
                    e.Item.BackColor = Color.LightGray;

                }
                if (p.BrojPoena >= 5)
                {

                    e.Item.BackColor = Color.LightYellow;

                }
                if (p.BrojPoena >= 10)
                {
                    e.Item.BackColor = Color.LightGreen;

                }
                if (p.BrojPoena < 3)
                {
                    e.Item.BackColor = Color.White;
                }

                ImageButton like = (ImageButton)e.Item.FindControl("btn_oLike");
                ImageButton unlike = (ImageButton)e.Item.FindControl("btn_oUnlike");
                if (korisnik != null)
                {
                    User_Likes ulo;
                    if (temp.getUserLikes(korisnik.id, p.id) == null)
                    {
                        ulo = new Data.EntityFramework.DAL.User_Likes();
                        ulo.PostId = p.id;
                        ulo.UserId = korisnik.id;
                        ulo.DatumLajkanja = DateTime.Now;
                        ulo.DaumRated = DateTime.Now;
                        ulo.isLiked = 0;
                        temp.SaveUser_Likes(ulo);
                    }
                    else
                    {
                        ulo = temp.getUserLikes(korisnik.id, p.id);
                    }
                    like.Enabled = false;
                    unlike.Enabled = false;

                    if (ulo.isLiked == 0)
                    {
                        like.Enabled = true;
                        unlike.Enabled = true;
                    }
                    if (ulo.isLiked == 1)
                    {
                        like.Enabled = false;
                        unlike.Enabled = true;
                    }
                    if (ulo.isLiked == 2)
                    {
                        like.Enabled = true;
                        unlike.Enabled = false;
                    }
                }
                else
                {
                    like.Enabled = false;
                    unlike.Enabled = false;
                }
            }
        }