Exemple #1
0
        public IActionResult GetFollowers(FollowDto dto)
        {
            var user      = _userService.GetUserByUsername(dto.Username);
            var followers = _followService
                            .GetUserFollows(user.Id)
                            .Select(f => (_userService.GetUserById(f.FollowingId)));

            var viewmodel = new PostUserViewModel()
            {
                UserId = user.Id,
                Users  = followers
            };

            return(PartialView("_UserList", viewmodel));
        }
Exemple #2
0
        public IActionResult Following(FollowDto dto)
        {
            var follower = _userService.GetCurrentUser(HttpContext.User);

            var follow = new Follow
            {
                FollowerId  = dto.FollowingId,
                FollowingId = follower.Id
            };
            var del_follow = _followService.GetFollow(follow.FollowerId, follow.FollowingId);

            if (del_follow == null)
            {
                _followService.Add(follow);
            }
            else
            {
                _followService.Remove(del_follow);
            }


            return(Ok());
        }