Exemplo n.º 1
0
        public async Task <System.Collections.ObjectModel.ObservableCollection <User> > GetUsersFromGroup(string groupId)
        {
            if (await EnsureLogin())
            {
                var userGroupService = new UserGroupService(base.AccessToken);
                var userGroups       = await userGroupService.GetUserGroupTableForGroup(groupId);

                var allUsers = await MobileService.GetTable <User>().ToCollectionAsync();

                ObservableCollection <User> groupUsers = new ObservableCollection <User>();
                foreach (var userGroup in userGroups)
                {
                    var user = allUsers.SingleOrDefault(u => u.Id == userGroup.UserId);
                    if (user != null)
                    {
                        groupUsers.Add(user);
                    }
                }
                return(groupUsers);
            }
            return(null);
        }