Example #1
0
        public void GetAllNotebooks()
        {
            var factory = new GraphNotebookFactory();
            var list    = factory.GetAllItems();

            Assert.IsNotNull(list);
            Assert.IsTrue(list.Count > 0);
        }
Example #2
0
        /// <summary>
        /// Creates OneNote notebook
        /// </summary>
        /// <returns></returns>
        private static Notebook OpenOrCreateNotebook()
        {
            // get notebooks
            Console.WriteLine("loading notebooks ...");
            var             notebookFactory = new GraphNotebookFactory();
            List <Notebook> notebooks       = notebookFactory.GetAllItems();
            var             notebook        = notebooks.FirstOrDefault(n => n.DisplayName == "Sample Notebook");

            // no notebooks, creating new one
            if (notebook == null)
            {
                notebook = notebookFactory.AddItem(new Notebook {
                    DisplayName = "Sample Notebook"
                });
                Console.WriteLine($"Created notebook: {notebook.DisplayName}");
            }

            return(notebook);
        }