public async static Task <ISiteListsCollectionPage> GetSiteLists(string groupId, string siteId)
        {
            _graphClient = GraphServiceClientProvider.GetAuthenticatedClient();
            ISiteListsCollectionPage lists = await _graphClient
                                             .Groups[groupId]
                                             .Sites[siteId]
                                             .Lists.Request().GetAsync();

            return(lists);
        }
        static async Task Main(string[] args)
        {
            // Get an authenticated client
            _graphClient = GraphServiceClientProvider.GetAuthenticatedClient();

            // Get the logged-in user
            user = _graphClient.Me.Request().GetAsync().Result;

            // Get all the SharePoint Lists
            lists = await GetList();

            // Get the list of members from SharePoint
            await RetrieveListItemsFromSharePoint(_member);

            // Add the logged-in user to the SharePoint Lists (if they don't exist)
            await AddLoggedInUser();

            await RetrieveListItemsFromSharePoint(_officeItem);
            await RetrieveListItemsFromSharePoint(_officeBook);

            MenuSelection();
        }
Exemplo n.º 3
0
        private async static void GetAuthors()
        {
            ISiteListsCollectionPage lists = await GetList();

            /* We will show existing site list
             * and filter the Authors List for use
             * in this sample
             */
            var list = lists.Where(l => l.DisplayName.Contains("Authors")).FirstOrDefault();

            //Show existing Site List in the Current Site
            Console.WriteLine($"Display all {list.DisplayName}");
            Console.WriteLine("***************************");

            //assign the global listId for use in other methods
            _listId = list.Id;

            //Getting listItems using msgraph
            IListItemsCollectionPage listItems = await GetListItems(list.Id);

            foreach (var item in listItems)
            {
                IDictionary <string, object> columns = item.Fields.AdditionalData;

                if (columns != null)
                {
                    string[] filterColumns = new string[] { "Title", "LastName" };
                    foreach (var col in columns)
                    {
                        if (filterColumns.Contains(col.Key))
                        {
                            Console.WriteLine($"Id: {item.Id} Field: {col.Key} Value: {col.Value}");
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        private async static Task <ISiteListsCollectionPage> GetList()
        {
            ISiteListsCollectionPage lists = await Sites.GetSiteLists(_groupId, _siteId);

            return(lists);
        }
        static async Task Main(string[] args)
        {
            lists = await GetList();

            MenuSelection();
        }