Example #1
0
        public async Task <ActionResult <IEnumerable <FollowModel> > > GetAllFollowedByUsername(string username)
        {
            var profile = await _profileService.GetProfileByUsername(username);

            if (profile == null)
            {
                return(NotFound());
            }
            var follows = await _followService.GetFollowByFollowerId(profile.UserId);

            var followsModel = _mapper.Map <IEnumerable <Follow>, IEnumerable <FollowModel> >(follows);

            foreach (FollowModel follow in followsModel)
            {
                var profile1 = await _profileService.GetProfileById(follow.UserId);

                var profile2 = await _profileService.GetProfileById(follow.FollowerId);

                follow.Username         = profile1.Username;
                follow.FollowerUsername = profile2.Username;
            }
            return(Ok(followsModel));
        }