コード例 #1
0
        public void GetLikeProfiles()
        {
            User         first   = CreateMockingUser();
            User         second  = CreateMockingUser();
            LikeProfiles newLike = users.GetLikeProfiles(first.UserId, second.UserId);
            LikeProfiles success = users.GetLikeProfiles(first.UserId, second.UserId);

            Assert.AreEqual(newLike.UserId, first.UserId);
            Assert.AreEqual(success.LikeId, newLike.LikeId);
        }
コード例 #2
0
        public void CreateDislike()
        {
            User         first  = CreateMockingUser();
            User         second = CreateMockingUser();
            LikeProfiles like   = users.CreateDislike(first.UserId, second.UserId);
            LikeProfiles unlike = users.CreateDislike(first.UserId, second.UserId);

            Assert.AreEqual(like.UserId, first.UserId);
            Assert.AreEqual(like.ToUserId, second.UserId);
        }
コード例 #3
0
        public LikeProfiles CreateDislike(int UserId, int OpposideUserId)
        {
            LikeProfiles like = GetLikeProfiles(UserId, OpposideUserId);

            like.Dislike = like.Dislike == true ? false : true;
            if (like.Dislike && like.Like)
            {
                like.Like = false;
            }
            context.LikeProfile.Update(like);
            context.SaveChanges();
            return(like);
        }
コード例 #4
0
        public void DislikeUser()
        {
            User      first  = CreateMockingUser();
            User      second = CreateMockingUser();
            UserCache cache  = new UserCache()
            {
                user_token            = first.UserToken,
                opposide_public_token = second.UserPublicToken
            };
            LikeProfiles dislike = users.DislikeUser(cache, ref message);
            LikeProfiles unlike  = users.DislikeUser(cache, ref message);

            Assert.AreEqual(dislike.UserId, first.UserId);
            Assert.AreEqual(dislike.ToUserId, second.UserId);
        }
コード例 #5
0
        public ActionResult <dynamic> DislikeUsers(UserCache cache)
        {
            string       message = null;
            LikeProfiles dislike = users.DislikeUser(cache, ref message);

            if (dislike != null)
            {
                return(new
                {
                    success = true,
                    data = new
                    {
                        disliked_user = dislike.Dislike,
                        liked_user = dislike.Like
                    }
                });
            }
            return(Return500Error(message));
        }
コード例 #6
0
        public LikeProfiles GetLikeProfiles(int userId, int toUserId)
        {
            LikeProfiles like = context.LikeProfile.Where(l
                                                          => l.UserId == userId &&
                                                          l.ToUserId == toUserId).FirstOrDefault();

            if (like == null)
            {
                like = new LikeProfiles()
                {
                    UserId   = userId,
                    ToUserId = toUserId,
                    Like     = false,
                    Dislike  = false
                };
                context.LikeProfile.Add(like);
                context.SaveChanges();
            }
            return(like);
        }