Ejemplo n.º 1
0
 //
 public void AddLike(string UserNickname, ObjectId postId)
 {
     try
     {
         repository.AddLike(UserNickname, postId);
     }
     catch
     {
     }
 }
Ejemplo n.º 2
0
 public void Like(string userName, string postId)
 {
     if (IsLiked(userName, postId))
     {
         postRepository.RemoveLike(userName, postId);
     }
     else
     {
         postRepository.AddLike(userName, postId);
     }
 }
Ejemplo n.º 3
0
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        public IActionResult Like(int id)
        {
            var claimsIdentity = (ClaimsIdentity)this.User.Identity;
            var claim          = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier);

            if (claim != null)
            {
                var userId = claim.Value;
                _context.AddLike(userId, id);
            }
            return(RedirectToAction(nameof(Index), "Home"));
        }
Ejemplo n.º 4
0
        public async Task DisLike()
        {
            PostRepository postRepository = new PostRepository();
            //Act
            var like = new Like {
                Name = "baran", PostID = 3, UserID = 9
            };
            LikeResult isLiked = await postRepository.AddLike(like);

            // Assert
            Assert.True(isLiked.IsSuccess);
        }
Ejemplo n.º 5
0
 private void Like(object sender, RoutedEventArgs e)
 {
     if (tempLike == false)
     {
         btnLike.Background = Brushes.Green;
         tempLike           = true;
         postRepository.AddLike(services.NickNameRead(), currentPost.Id);
         txtLike.Text = postServices.GetLikes(currentPost.Id).ToString();
     }
     else
     {
         Color           color = (Color)ColorConverter.ConvertFromString("#0288d1");
         SolidColorBrush brush = new SolidColorBrush(color);
         btnLike.Background = brush;
         tempLike           = false;
         txtLike.Text       = postServices.GetLikes(currentPost.Id).ToString();
     }
 }