Exemple #1
0
        public async Task <IEnumerable <UserInfo> > SearchWithFriends(UserSearchOption option, PageOptions page)
        {
            var users = await Search(null, page);             // get user info from cache or db

            var fromService = _conf["FriendService:From"];
            var virtualPath = _conf["FriendService:VirtualPath"];

            using (var client = new HttpClient())
            {
                var friends = await client.PostAsync <List <FriendViewModel>, ConsulService>(fromService, virtualPath, null, new { SubscriberId = option.UserId, ServiceId = option.ServiceId }, _serviceFinder, _loadBalancer);                // get friend info from cache or db

                foreach (var friend in friends)
                {
                    // aggregate friend and user data
                    var user = users.FirstOrDefault(x => x.UserId == friend.TargetId.ToGuid());
                    if (!user.IsNull())
                    {
                        user.IsFriend = true;
                    }
                }
            }

            return(users);
        }
Exemple #2
0
        public IEnumerable <SystemRole> Search(Expression <Func <SystemRole, bool> > whereExpressions, PageOptions page)
        {
            var query = whereExpressions == null?RoleDb.AsQueryable() : RoleDb.AsQueryable().Where(whereExpressions);

            if (!page.IsNull() && page.IsValidate)
            {
                var totalCount = 0;
                var results    = query.ToPageList(page.PageIndex, page.PageSize, ref totalCount);
                page.TotalCount = totalCount;

                return(results);
            }
            else
            {
                return(query.ToList());
            }
        }
Exemple #3
0
        public async Task <IEnumerable <UserInfo> > Search(Expression <Func <UserInfo, bool> > whereExpressions, PageOptions page)
        {
            var query   = whereExpressions.IsNull() ? UserDb.AsQueryable() : UserDb.AsQueryable().Where(whereExpressions);
            var results = new List <UserInfo>();

            if (!page.IsNull() && page.IsValidate)
            {
                results = await query.ToPageListAsync(page.PageIndex, page.PageSize);

                page.TotalCount = query.Count();
            }
            else
            {
                results = await query.ToListAsync();
            }

            return(results);
        }