예제 #1
0
        private void BtnGreateComment_Click(object sender, RoutedEventArgs e)
        {
            var commentsGame = new CommentsGame();

            commentsGame.Text     = TxtComment.Text;
            commentsGame.IdGame   = IdGame;
            commentsGame.IdUser   = Classes.IdUserClass.IdUser;
            commentsGame.Datetime = DateTime.Now;

            Entities.GetContext().Entry(commentsGame).State = EntityState.Added;

            Entities.GetContext().SaveChanges();

            DoLStComment();
        }
예제 #2
0
        private void LikeComment_Click(object sender, RoutedEventArgs e)
        {
            Button cmd = (Button)sender;

            if (cmd.DataContext is CommentsGame)
            {
                CommentsGame comment = (CommentsGame)cmd.DataContext;

                var commentsGame = comment;

                if (cmd.Background != Brushes.Green)
                {
                    commentsGame.CountLike += 1;
                }
                else
                {
                    commentsGame.CountLike -= 1;
                    DeleteCommentGameHist(comment.IdComments);
                }

                Entities.GetContext().Entry(commentsGame).State = EntityState.Modified;

                Entities.GetContext().SaveChanges();

                if (Entities.GetContext().CommentGameHistory.Where(i => i.IdComment == comment.IdComments && i.IdUser == Classes.IdUserClass.IdUser).Any())
                {
                    commentsGame.CountDisLike -= 1;
                    EditCommentGameHist(comment.IdComments, "Like");
                }
                else if (cmd.Background != Brushes.Green)
                {
                    AddCommentGameHist(comment.IdComments, "Like");
                }

                DoLStComment();
            }
        }