Beispiel #1
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);
        }