Ejemplo n.º 1
0
        public async Task <ActionResult <FollowResponseModel> > FollowAsync(FollowInputModel inputModel)
        {
            var  followingUserId = this.userManager.GetUserId(this.User);
            bool isFollowed      = await this.followService.FollowAsync(inputModel.FollowedUserId, followingUserId);

            return(new FollowResponseModel {
                IsFollowed = isFollowed
            });
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <FollowResponseModel> > Follow(FollowInputModel input)
        {
            var userToFollow = await this.userManager.FindByIdAsync(input.UserId);

            if (userToFollow == null)
            {
                return(this.NotFound());
            }

            var currentUserId = this.userManager.GetUserId(this.User);
            var isSuccessful  = await this.followsService.FollowUserAsync(currentUserId, input.UserId);

            return(isSuccessful);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Post(FollowInputModel followInput)
        {
            var response = new Response();
            var user     = await this.userManager.FindByIdAsync(followInput.FollowedId);

            if (user == null)
            {
                response.Message = "No such user!";
                return(this.NotFound(response));
            }

            followInput.FollowerId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

            await this.followsService.AddAsync(followInput);

            response.Message = "Successfully added follow.";

            return(this.Ok(response));
        }