Example #1
0
        public void CreateNotebook()
        {
            var notebookInst = new Notebook
            {
                DisplayName = "New Notebook",
            };

            var factory  = new GraphNotebookFactory();
            var notebook = factory.AddItem(notebookInst);

            Assert.IsNotNull(notebook.Id);
            Assert.IsTrue(notebook.DisplayName.Equals(notebookInst.DisplayName));
        }
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);
        }