Ejemplo n.º 1
0
 public Follow CheckFollow(FollowingUser user)
 {
     try
     {
         Follow follow = _dbContext.GetFollows().Where(f => f.UserFollowingID == user.FromUserId && f.UserFollowedID == user.ToUserId).First();
         return(follow);
     }
     catch
     {
         return(null);
     }
 }
Ejemplo n.º 2
0
        public string Follow(FollowingUser user)
        {
            Follow newFollow = new Follow
            {
                UserFollowingID = user.FromUserId,
                UserFollowedID  = user.ToUserId,
                CreatedDate     = DateTime.Now
            };

            _profileDA.Follow(newFollow);

            return("success");
        }
Ejemplo n.º 3
0
        public string Unfollow(FollowingUser user)
        {
            string response = "success";
            Follow check    = _profileDA.CheckFollow(user);

            if (check != null)
            {
                _profileDA.Unfollow(check);
            }
            else
            {
                response = "fail";
            }


            return(response);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds a new FollowingUser object into the database
        /// Checks if both the follower and followee exists, on id
        /// If either follower or followee does not exist, return true
        /// If successul in adding to database, return true
        /// </summary>
        /// <param name="newFollow"></param>
        /// <returns></returns>
        public async Task <bool> FollowUser(FollowingUser newFollow)
        {
            if (!UserExistsById(newFollow.FollowerUserId))
            {
                _logger.LogWarning($"RepoLogic.Follower() was called for a userid(follower) that does not exist {newFollow.FollowerUserId}.");
                return(false);
            }
            if (!UserExistsById(newFollow.FolloweeUserId))
            {
                _logger.LogWarning($"RepoLogic.Follower() was called for a userid(follower) that does not exist {newFollow.FolloweeUserId}.");
                return(false);
            }
            await _dbContext.AddAsync <FollowingUser>(newFollow);

            await _dbContext.SaveChangesAsync();

            return(true);
        }
        public bool FollowUser(int?id)
        {
            bool result = false;
            int  userId = Convert.ToInt32(Session["UserId"]);

            if (ModelState.IsValid && Session["UserId"] != null && id != userId && id != null)
            { //int userId = Convert.ToInt32(Session["UserId"]);
                var temp = db.FollowingUser.Where(f => f.UserId == userId && f.FollowingUserId == id).FirstOrDefault();
                if (temp == null)
                {
                    FollowingUser user = new FollowingUser();
                    user.UserId          = userId;
                    user.FollowingUserId = Convert.ToInt32(id);
                    db.FollowingUser.Add(user);
                    db.SaveChanges();
                    result = true;
                }
            }
            return(result);
        }
Ejemplo n.º 6
0
        public ActionResult Unfollow(FollowingUser data)
        {
            string response = _profileBL.Unfollow(data);

            return(Json(response));
        }