Пример #1
0
        public IActionResult Unlike(LikeIn likeIn)
        {
            if (_postSvc.Unlike(likeIn.PostId, likeIn.UserId) == false)
            {
                return(Ok(new
                {
                    success = true,
                    reason = "Failed to Unlike Post",
                }));
            }

            return(Ok(new
            {
                success = true,
            }));
        }
Пример #2
0
        public IActionResult AddLikes([FromBody] LikeIn model)
        {
            var like = new Like
            {
                UserId     = model.UserId,
                FeedBackId = model.FeedBackId,
                CommentId  = model.CommentId,
                IsLike     = model.IsLike
            };

            DbContext.Likes.Add(like);
            DbContext.SaveChanges();
            var like1 = DbContext.Likes.Where(x => x.UserId == model.UserId && x.FeedBackId == model.FeedBackId && x.CommentId == model.CommentId).ProjectToType <LikeDTO>().FirstOrDefault();

            return(new JsonResult(
                       like1,
                       new JsonSerializerSettings()
            {
                Formatting = Formatting.Indented
            }));
        }