示例#1
0
        public void CreateFollowUserFromRequest(FollowUser followUser, IFollowRequestService groupRequestService)
        {
            var oldUser = followUserRepository.GetMany(g => g.FromUserId == followUser.FromUserId && g.ToUserId == followUser.ToUserId);

            if (oldUser.Count() == 0)
            {
                followUserRepository.Add(followUser);
                SaveFollowUser();
            }
            groupRequestService.ApproveRequest(followUser.ToUserId, followUser.FromUserId);
        }
示例#2
0
        public IPagedList <Group> GetGroups(string userId, GroupFilter filter, Page page)
        {
            switch (filter)
            {
            case GroupFilter.All:
            {
                return(groupRepository.GetPage(page, x => true, order => order.GroupName));
            }

            case GroupFilter.MyGroups:
            {
                var groupsIds = groupUserrepository.GetMany(gru => gru.UserId == userId && gru.Admin).Select(gru => gru.GroupId);
                return(groupRepository.GetPage(page, where => groupsIds.Contains(where.GroupId), order => order.CreatedDate));
            }

            case GroupFilter.MyFollowingsGroups:
            {
                var userIds  = followUserrepository.GetMany(g => g.FromUserId == userId).Select(x => x.ToUserId);
                var groupIds = from item in userIds from gruser in groupUserrepository.GetMany(g => g.UserId == item) select gruser.GroupId;
                return(groupRepository.GetPage(page, where => groupIds.Contains(where.GroupId), order => order.CreatedDate));
            }

            case GroupFilter.MyFollowedGroups:
            {
                var groupIds = groupUserrepository.GetMany(g => (g.UserId == userId) && (g.Admin == false)).Select(item => item.GroupId);
                return(groupRepository.GetPage(page, where => groupIds.Contains(where.GroupId), order => order.CreatedDate));
            }

            default:
            {
                throw new ApplicationException("Filter not understood");
            }
            }
        }
示例#3
0
        public IEnumerable <Comment> GetTop20CommentsOfPublicGoalFollwing(string userId)
        {
            //var comment = from c in commentRepository.GetMany(c => c.Update.Goal.GoalType == false) where (from f in followUserRepository.GetMany(fol => fol.FromUserId == userId) select f.ToUserId).ToList().Contains(c.Update.Goal.UserId) select c;
            var commentUsers = (from f in followUserRepository.GetMany(fol => fol.FromUserId == userId)
                                join com in (from cu in commentUserRepository.GetAll()
                                             select cu) on f.ToUserId equals com.UserId select com).ToList();

            var comments = from c in commentRepository.GetMany(c => c.Update.Goal.GoalType == false)
                           join com in commentUsers on c.CommentId equals com.CommentId
                           select c;


            return(comments);
        }
示例#4
0
        public IEnumerable <Update> GetTop20UpdatesOfFollowing(string userid)
        {
            var updates = from u in updateRepository.GetMany(u => (u.Goal.GoalType == false)) where (from f in followUserRepository.GetMany(fol => fol.FromUserId == userid) select f.ToUserId).ToList().Contains(u.Goal.UserId) select u;

            return(updates);
        }
示例#5
0
        public IEnumerable <Support> GetTop20SupportsOfFollowings(string userId)
        {
            //var supports = SupportRepository.GetMany(s => s.Goal.GoalType == false).OrderByDescending(s => s.SupportedDate).Take(20).ToList();
            var supports = (from s in _supportRepository.GetMany(s => s.Goal.GoalType == false) where (from f in _followUserRepository.GetMany(fol => fol.FromUserId == userId) select f.ToUserId).ToList().Contains(s.UserId) select s).OrderByDescending(s => s.SupportedDate).Take(20);

            return(supports);
        }
示例#6
0
        public IEnumerable <Goal> GetGoalsofFollowing(string userid)
        {
            var goals = (from g in _goalRepository.GetMany(g => g.GoalType == false) where (from f in _followUserrepository.GetMany(fol => fol.FromUserId == userid) select f.ToUserId).ToList().Contains(g.UserId) select g).OrderByDescending(g => g.CreatedDate);

            return(goals);
        }