private UserJokeInteractionStatus GetStatus(int jokeId)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(UserJokeInteractionStatus.Unauthenticated);
            }
            var          userRepo   = new UserRepository(_connectionString);
            var          user       = userRepo.GetByEmail(User.Identity.Name);
            var          jokeRepo   = new JokesRepository(_connectionString);
            UserJokeLike likeStatus = jokeRepo.GetLike(user.Id, jokeId);

            if (likeStatus == null)
            {
                return(UserJokeInteractionStatus.NeverInteracted);
            }
            if (likeStatus.Date.AddMinutes(MinutesAllowedToChangeLike) < DateTime.Now)
            {
                return(UserJokeInteractionStatus.CanNoLongerInteract);
            }
            return(likeStatus.Like
                ? UserJokeInteractionStatus.Liked
                : UserJokeInteractionStatus.Disliked);
        }
Exemple #2
0
        public StatusOfUser GetStatus(int JokeId)
        {
            var            userRepo   = new AccountRepository(_connectionString);
            var            user       = userRepo.GetByEmail(User.Identity.Name);
            var            jokeRepo   = new JokesRepository(_connectionString);
            UserLikedJokes likeStatus = jokeRepo.GetLike(user.Id, JokeId);

            if (likeStatus == null)
            {
                return(StatusOfUser.NeverInteracted);
            }

            else if (likeStatus.Date.AddMinutes(MinutesAllowedToChangeLike) < DateTime.Now)
            {
                return(StatusOfUser.CanNoLongerInteract);
            }

            else if (likeStatus.Liked == true)
            {
                return(StatusOfUser.Liked);
            }

            return(StatusOfUser.Disliked);
        }