Example #1
0
        public async Task <int> GetLike([FromBody] FindworkRequest request)
        {
            var provider_id = Int32.Parse(User.Identity.Name);
            //status
            var temp = await LikeAccessor.Find(provider_id, request.work_id);

            //-1是首次点赞
            if (temp == -1)
            {
                var temp_a = await LikeAccessor.Create(provider_id, request.work_id);

                if (temp_a < 0)//点赞失败
                {
                    return(-1);
                }
            }
            else
            {
                var temp_b = await LikeAccessor.Change(provider_id, request.work_id, temp);

                if (temp_b == -1)
                {
                    return(-1);
                }
                else if (temp_b == 0)
                {
                    await WorkAccessor.getnolike(request.work_id);

                    return(0);
                }
            }
            await WorkAccessor.getlike(request.work_id);

            return(1);
        }
Example #2
0
        public async Task <int> ShowLike([FromBody] FindworkRequest request)
        {
            var provider_id = Int32.Parse(User.Identity.Name);
            //status
            var temp = await LikeAccessor.Find(provider_id, request.work_id);

            //-1是首次点赞
            if (temp == -1)
            {
                return(0);
            }
            else
            {
                return(temp);
            }
        }