public void CommentDislike(string userId, int commentId, string likeSpan, string dislikeSpan) { Dislikes dislike = repository.Dislikes .FirstOrDefault(d => d.For == "Comment" && d.ForId == commentId && d.UserId == userId); if (dislike == null) { dislike = new Dislikes { For = "Comment", ForId = commentId, UserId = userId }; repository.AddDislike(dislike); //notification _ = ShowNotification(userId, commentId); } else { repository.DeleteDislike(dislike.Id); } _ = CommentLikesDislikesInitial(userId, commentId, likeSpan, dislikeSpan); }
public ActionResult AddDislike(string userId, string For, int forId, string spanId) { ViewData["Id"] = userId; Dislikes dislike = new Dislikes { For = For, ForId = forId, UserId = userId }; repository.AddDislike(dislike); return(PartialView("LikesDislikesCount", new LikesDislikes { For = For, ForId = forId, spanId = spanId, Likes = repository.Likes.Where(l => l.For == For && l.ForId == forId), Dislikes = repository.Dislikes.Where(d => d.For == For && d.ForId == forId) })); }
public async Task VideoDislikes(int videoId, string userId) { bool likeInd = false; bool dislikeInd = false; Dislikes dislike = repository.Dislikes .FirstOrDefault(d => d.For == "Video" && d.ForId == videoId && d.UserId == userId); if (dislike == null) { dislike = new Dislikes { For = "Video", ForId = videoId, UserId = userId }; repository.AddDislike(dislike); dislikeInd = true; _ = ShowNotification(userId, videoId); } else { repository.DeleteDislike(dislike.Id); } int totalLikes = repository.Likes .Where(l => l.For == "Video" && l.ForId == videoId) .Count(); int totalDislikes = repository.Dislikes .Where(d => d.For == "Video" && d.ForId == videoId) .Count(); await Clients.All.SendAsync("AddRemoveDislike", videoId, userId, totalLikes, likeInd, totalDislikes, dislikeInd); }