Example #1
0
        public IHttpActionResult Follow(FollowingDTO dto)
        {
            var userId = User.Identity.GetUserId();

            var following = _unitOfWork.Followings.GetFollowing(userId, dto.FolloweeId);

            //if (_context.Followings.Any(f => f.FollowerId == userId && f.FolloweeId == dto.FolloweeId))
            if (following != null)
            {
                return(BadRequest("Following already exists."));
            }

            following = new Following
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId
            };

            //_context.Followings.Add(following);
            //_context.SaveChanges();
            _unitOfWork.Followings.Add(following);
            _unitOfWork.Complete();

            return(Ok());
        }
        public FollowingModel GetFollowing(string id, string maxResults, string paginationToken)
        {
            UsersClient client = new UsersClient(_oAuthInfo);

            // these override the base behaviour for the user service when fetching followers
            string tweetFields = "attachments,author_id,context_annotations,conversation_id,created_at,entities,geo,id,in_reply_to_user_id,lang,non_public_metrics,public_metrics,organic_metrics,promoted_metrics,possibly_sensitive,referenced_tweets,reply_settings,source,text,withheld";
            string userFields  = "created_at,description,entities,id,location,name,pinned_tweet_id,profile_image_url,protected,public_metrics,url,username,verified,withheld";

            string followersJson = client.GetFollowing(id, _expansionsFields, maxResults, paginationToken, tweetFields, userFields);

            FollowingDTO resultsDTO = JsonConvert.DeserializeObject <FollowingDTO>(followersJson);

            FollowingModel models = _iMapper.Map <FollowingDTO, FollowingModel>(resultsDTO);

            return(models);
        }
Example #3
0
        public IHttpActionResult Unfollow(FollowingDTO dto)
        {
            string    userId    = User.Identity.GetUserId();
            Following following = db.Followings.FirstOrDefault(x => x.FollowerId == userId && x.FolloweeId == dto.ArtistID);

            if (following != null)
            {
                db.Followings.Remove(following);
                db.SaveChanges();
                return(Ok());
            }

            else
            {
                return(NotFound());
            }
        }
        public IHttpActionResult Follow(FollowingDTO dTO)
        {
            var userId = User.Identity.GetUserId();

            if (_context.Followings.Any(a => a.FollowerId == userId && a.FolloweeId == dTO.FolloweeId))
            {
                return(BadRequest("The following already exists"));
            }
            var following = new Following
            {
                FollowerId = userId,
                FolloweeId = dTO.FolloweeId
            };

            _context.Followings.Add(following);
            _context.SaveChanges();
            return(Ok());
        }
Example #5
0
        public IActionResult Follow(FollowingDTO dto)
        {
            var userId = _userManager.GetUserId(User);

            if (_unitOfWork.Followings.GetFollowing(dto.FolloweeId, userId) != null)
            {
                return(BadRequest("Following Allready Exist"));
            }

            var following = new Following
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId
            };

            _context.Followings.Add(following);
            _context.SaveChanges();

            return(Ok());
        }
Example #6
0
        public IHttpActionResult Follow(FollowingDTO followingDto)
        {
            var userId = User.Identity.GetUserId();

            if (_dbContext.Follwings.Any(f => f.FollowerId == userId && f.FolloweeId == followingDto.FolloweeId))
            {
                return(BadRequest("Following already exists!!"));
            }

            var following = new Following
            {
                FollowerId = userId,
                FolloweeId = followingDto.FolloweeId
            };

            _dbContext.Follwings.Add(following);
            _dbContext.SaveChanges();

            return(Ok());
        }
Example #7
0
        public IHttpActionResult Follow(FollowingDTO dto)
        {
            var userId = User.Identity.GetUserId();

            if (_context.Followings.Any(f => f.FolloweeId == userId && f.FolloweeId == dto.FolloweeId))
            {
                return(BadRequest("Le suivi exists déjà!"));
            }

            var following = new Following
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId
            };

            _context.Followings.Add(following);
            _context.SaveChanges();

            return(Ok());
        }
Example #8
0
        public IHttpActionResult Follow(FollowingDTO dto)
        {
            string userId = User.Identity.GetUserId();
            bool   exists = db.Followings.Any(x => x.FollowerId == userId && x.FolloweeId == dto.ArtistID);

            if (!exists)
            {
                Following following = new Following();
                following.FolloweeId = dto.ArtistID;
                following.FollowerId = userId;

                db.Followings.Add(following);
                db.SaveChanges();
                return(Ok());
            }

            else
            {
                return(BadRequest("You are already attending this event"));
            }
        }
        public IHttpActionResult Follow(FollowingDTO dto)
        {
            var userId = User.Identity.GetUserId(); //GET USERIS

            //CHECK EXSISTS

            if (_context.Followings.Any(f => f.FolloweeId == userId && f.FolloweeId == dto.FolloweeId))
            {
                return(BadRequest("The attendance alreday exsist!"));
            }

            var following = new Following
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId
            };

            _context.Followings.Add(following);
            _context.SaveChanges();
            return(OK());
        }
Example #10
0
        public IHttpActionResult Follow(FollowingDTO dto)
        {
            var userId     = User.Identity.GetUserId();
            var duplicated = _unitOfWork.Followings.GetFollowing(dto.FolloweeId, userId) != null;

            if (duplicated)
            {
                return(BadRequest("Following already exists"));
            }

            var following = new Following
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId
            };

            _unitOfWork.Followings.Add(following);
            _unitOfWork.Complete();

            return(Ok());
        }
        public IHttpActionResult Follow(FollowingDTO followingdto)
        {
            var UserId  = User.Identity.GetUserId();
            var IsExist = _context.Followings.Any(f => f.FollowerId == UserId && f.FolloweeId == followingdto.followeeId);

            if (IsExist == true)
            {
                return(BadRequest("Following Already Exists !!! "));
            }
            else
            {
                var following = new Following
                {
                    FollowerId = UserId,
                    FolloweeId = followingdto.followeeId
                };
                _context.Followings.Add(following);
                _context.SaveChanges();

                return(Ok());
            }
        }
Example #12
0
        public IHttpActionResult Follow(FollowingDTO dto)
        {
            var userId = User.Identity.GetUserId();

            var following = context.Follows.Any(f => f.FolloweeID == userId && f.FolloweeID == dto.FolloweeId);

            if (following)
            {
                return(BadRequest("Follow already exists!"));
            }

            var follow = new Follow
            {
                FollowerId = userId,
                FolloweeID = dto.FolloweeId
            };

            context.Follows.Add(follow);
            context.SaveChanges();

            return(Ok());
        }
Example #13
0
        public IHttpActionResult Follow(FollowingDTO dto)
        {
            var userId = User.Identity.GetUserId();

            var following = _unitofWork.Followings.GetFollowing(userId, dto.FolloweeId);

            if (null != following)
            {
                return(BadRequest("Ya estás siguiendo a este usuario."));
            }

            following = new Following
            {
                FollowerId = userId,
                FolloweeId = dto.FolloweeId
            };

            _unitofWork.Followings.Add(following);

            _unitofWork.Complete();

            return(Ok());
        }
Example #14
0
        public IHttpActionResult Follow(FollowingDTO dto)
        {
            var currentlyloggedUserId = User.Identity.GetUserId(); //follower wants to follow below artist
            var followeeId            = dto.FolloweeId;            //leader ,to be followed

            #region Check if Repeated

            var isFound =
                dbContext.Following.Any(e => e.FollowerId == currentlyloggedUserId && e.FolloweeId == followeeId);
            if (isFound)
            {
                return(BadRequest("You already Following this Artist"));
            }

            #endregion
            var followingRelation = new FollowingRelation()
            {
                FollowerId = currentlyloggedUserId,
                FolloweeId = followeeId
            };
            dbContext.Following.Add(followingRelation);
            dbContext.SaveChanges();
            return(Ok());
        }