static void Main(string[] args) { graphClient = GraphServiceClientProvider.GetAuthenticatedClient(); cal = new CalendarController(graphClient); RunAsync().GetAwaiter().GetResult(); Console.WriteLine("Available commands:\n" + "\t 1. schedule-event \n " + "\t 2. schedule-recurrent-event \n " + "\t 3. book-room \n " + "\t 4. schedule-allday-event \n " + "\t 5. accept-event \n " + "\t 6. decline-event \n" + "\t exit"); var command = ""; do { Console.Write("> "); command = Console.ReadLine(); if (command != "exit") { RunAsync(command).GetAwaiter().GetResult(); } }while (command != "exit"); }
/// <summary> /// Gets a User from Microsoft Graph /// </summary> /// <returns>A User object</returns> public static async Task <User> GetMeAsync() { User currentUser = null; try { var graphClient = GraphServiceClientProvider.GetAuthenticatedClient(); // Request to get the current logged in user object from Microsoft Graph currentUser = await graphClient.Me.Request().GetAsync(); return(currentUser); } catch (ServiceException e) { Debug.WriteLine("We could not get the current user: " + e.Error.Message); return(null); } }
static void Main(string[] args) { bool loginCancelled = false; graphClient = GraphServiceClientProvider.GetAuthenticatedClient(); cal = new CalendarController(graphClient); try { RunAsync().GetAwaiter().GetResult(); loginCancelled = true; } catch (Exception ex) { Console.Write("User cancelled login, press enter to exit..."); Console.ReadLine(); } if (loginCancelled == true) { Console.WriteLine("Available commands:\n" + "\t 1. schedule-event \n " + "\t 2. schedule-recurrent-event \n " + "\t 3. book-room \n " + "\t 4. schedule-allday-event \n " + "\t 5. accept-event \n " + "\t 6. decline-event \n" + "\t exit"); var command = ""; do { Console.Write("> "); command = Console.ReadLine(); if (command != "exit") { runAsync(command).GetAwaiter().GetResult(); } }while (command != "exit"); } }