コード例 #1
0
        private Like GetLikeByUserAndKweetId(int userId, int kweetId)
        {
            ServiceHelpers.CheckValidId(userId);
            ServiceHelpers.CheckValidId(kweetId);

            return(_repository.Find(l => l.UserId.Equals(userId) && l.KweetId.Equals(kweetId)));
        }
コード例 #2
0
        public bool TryFindByUserAndFollowsId(int userId, int followsId, out Follower follower)
        {
            ServiceHelpers.CheckValidId(userId);
            ServiceHelpers.CheckValidId(followsId);

            follower = _repository.Find(f => f.UserId.Equals(userId) && f.FollowsId.Equals(followsId));
            return(follower != null);
        }
コード例 #3
0
        public async Task <ICollection <Kweet> > GetTimeLineForUserIdAsync(int userId, int from, int to)
        {
            ServiceHelpers.CheckValidId(userId);
            ServiceHelpers.CheckRange(from, to);

            return(await _repository.GetNewestKweetsByQueryAsync(
                       (kweet => kweet.UserId.Equals(userId) || kweet.User.Followers.Any(f => f.UserId.Equals(userId))),
                       from,
                       to));
        }
コード例 #4
0
        public async Task RemoveRangeByKweetIdAsync(int kweetId)
        {
            ServiceHelpers.CheckValidId(kweetId);

            var likes = await _repository.FindRangeAsync(l => l.KweetId.Equals(kweetId));

            if (likes.Count > 0)
            {
                _repository.DeleteRange(likes);
            }
        }
コード例 #5
0
        public async Task RemoveRangeByKweetIdAsync(int kweetId)
        {
            ServiceHelpers.CheckValidId(kweetId);

            var hashTagInKweets = await _repository.FindRangeAsync(h => h.KweetId.Equals(kweetId));

            if (hashTagInKweets.Count > 0)
            {
                _repository.DeleteRange(hashTagInKweets);
            }
        }
コード例 #6
0
        public async Task RemoveRangeByUserIdAsync(int userId)
        {
            ServiceHelpers.CheckValidId(userId);

            var followers = await _repository.FindRangeAsync(f => f.FollowsId.Equals(userId) || f.UserId.Equals(userId));

            if (followers.Count > 0)
            {
                _repository.DeleteRange(followers);
            }
        }
コード例 #7
0
        public async Task <Kweet> GetKweetWithLikesAsync(int id)
        {
            ServiceHelpers.CheckValidId(id);

            return(await _repository.FindAsync(k => k.Id.Equals(id)));
        }
コード例 #8
0
        public async Task <IEnumerable <HashTag> > GetTopAsync(int amount)
        {
            ServiceHelpers.CheckValidId(amount);

            return(await _repository.GetTopAsync(amount));
        }
コード例 #9
0
        public async Task <ICollection <ApplicationUser> > GetFollowers(int userId)
        {
            ServiceHelpers.CheckValidId(userId);

            return(await _repository.GetFollowers(userId));
        }
コード例 #10
0
        public async Task <ApplicationUser> GetById(int userId)
        {
            ServiceHelpers.CheckValidId(userId);

            return(await _repository.FindAsync(u => u.Id.Equals(userId)));
        }