示例#1
0
        public async Task <JsonResult> RatingDecrease([FromBody] int?id)
        {
            var userId      = _userManager.GetUserId(User); //gets the usersId
            var wholeThread = _service.GetById(id);
            var listOfLikes = _service.ListOfLikes(id);

            if (id == null)
            {
                NotFound();
            }
            if (_service.CheckAreadyLiked(wholeThread, userId) == true)
            {
                //remove the user from the table
                await _service.RemoveUserFromLikeList(id, userId);

                //show the decerase
                return(Json(listOfLikes.Count()));
            }
            else
            {
                return(Json(listOfLikes.Count()));    //makes a json with the amount of votes that are currently in the database
            }
        }