Esempio n. 1
0
        public async Task <IActionResult> UnFollowUser([FromBody] FollowAC unfollowAC)
        {
            await _unitOfWork.FollowRepository.UnFollow(unfollowAC);

            await _unitOfWork.Save();

            return(Ok(unfollowAC));
        }
Esempio n. 2
0
        public async Task <IActionResult> FollowUser([FromBody] FollowAC followAC)
        {
            var follow = await _unitOfWork.FollowRepository.FollowUser(followAC);

            await _unitOfWork.Save();

            return(Ok(follow));
        }
Esempio n. 3
0
        public async Task UnFollow(FollowAC followAC)
        {
            var userfollowed = await _context
                               .Follow
                               .Where(ob => ob.FollowingUserId == followAC.FollowedUserId && ob.FollowedUserId == followAC.FollowingUserId)
                               .FirstOrDefaultAsync();

            userfollowed.IsFollowed = false;

            _context.Follow.Update(userfollowed);
        }
Esempio n. 4
0
        public async Task <IEnumerable <FollowAC> > ListOfFollowersOfUser(string userId)
        {
            List <Follow> Followers = await _context
                                      .Follow
                                      .Include(o => o.FollowedUser)
                                      .Include(o => o.FollowingUser)
                                      .Where(ob => ob.FollowedUserId == userId && ob.IsFollowed == true)
                                      .ToListAsync();

            List <FollowAC> FollowerAcs = new List <FollowAC>();

            foreach (var follower in Followers)
            {
                FollowAC followAC = new FollowAC();
                followAC.Id              = follower.Id;
                followAC.FollowedUserId  = follower.FollowedUserId;
                followAC.FollowingUserId = follower.FollowingUserId;

                followAC.FollowingUser = new UserAC
                {
                    Id      = follower.FollowingUser.Id,
                    Name    = follower.FollowingUser.Name,
                    Phone   = follower.FollowingUser.PhoneNumber,
                    Email   = follower.FollowingUser.Email,
                    Address = follower.FollowingUser.Address
                };

                followAC.FollowedUser = new UserAC
                {
                    Id      = follower.FollowingUser.Id,
                    Name    = follower.FollowingUser.Name,
                    Phone   = follower.FollowingUser.PhoneNumber,
                    Email   = follower.FollowingUser.Email,
                    Address = follower.FollowingUser.Address
                };

                followAC.IsFollowed = follower.IsFollowed;
                FollowerAcs.Add(followAC);
            }

            return(FollowerAcs);
        }
Esempio n. 5
0
        public async Task <FollowAC> FollowUser(FollowAC followAC)
        {
            if (await IsExists(followAC.FollowingUserId, followAC.FollowedUserId) != null)
            {
                var followUser = await IsExists(followAC.FollowingUserId, followAC.FollowedUserId);

                followUser.IsFollowed = true;
                _context.Follow.Update(followUser);
            }

            else
            {
                await _context.Follow.AddAsync(new Follow
                {
                    FollowedUserId  = followAC.FollowedUserId,
                    FollowingUserId = followAC.FollowingUserId,
                    IsFollowed      = true
                });

                followAC.IsFollowed = true;
            }

            return(followAC);
        }