protected void btn_Unlike_Click(object sender, EventArgs 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 = 2; user_likes.Rate = 0; temp.SaveUser_Unlikes(user_likes); } else { Int32 LikesBefore = temp.getVoteUserLikes(user_likes.UserId.Value, user_likes.PostId.Value); user_likes.DatumLajkanja = DateTime.Now; user_likes.isLiked = 2; temp.UpdateUser_Likes(user_likes, LikesBefore); } } LoadClanak(post.id); }
protected void btn_oUnlike_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 = post.id; user_likes.UserId = korisnik.id; user_likes.DaumRated = DateTime.Now; user_likes.DatumLajkanja = DateTime.Now; user_likes.isLiked = 2; user_likes.Rate = 0; temp.SaveUser_Unlikes(user_likes); } else { Int32 LikesBefore = temp.getVoteUserLikes(user_likes.UserId.Value, user_likes.PostId.Value); user_likes.DatumLajkanja = DateTime.Now; user_likes.isLiked = 2; temp.UpdateUser_Likes(user_likes, LikesBefore); } } } LoadClanak(post.id); } else { ClientScript.RegisterStartupScript(this.GetType(), "", "Login()", true); } }