Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Graph .NET
>
Tutorial
> Get rooms
The following example shows how to get all the room objects in the tenant.
C# example
using System; using System.Threading.Tasks; using System.Collections.Generic; using Independentsoft.Graph; using Independentsoft.Graph.Calendars; namespace ConsoleApp1 { class Program { static async Task Main() { try { GraphClient client = new GraphClient(); client.ClientId = "63333333-209e-454e-b7bd-55a4d201270f"; client.Tenant = "independentsoft.onmicrosoft.com"; client.Username = "info@independentsoft.onmicrosoft.com"; client.Password = "password"; IList
rooms = await client.GetRooms(); foreach (Room room in rooms) { Console.WriteLine(room.Id); Console.WriteLine(room.DisplayName); Console.WriteLine(room.EmailAddress); Console.WriteLine(room.Capacity); Console.WriteLine(room.Building); Console.WriteLine(room.FloorNumber); Console.WriteLine(room.FloorLabel); if (room.Address != null) { Console.WriteLine(room.Address.Street); Console.WriteLine(room.Address.PostalCode); Console.WriteLine(room.Address.City); Console.WriteLine(room.Address.Country); } } } catch (GraphException ex) { Console.WriteLine("Error: " + ex.Code); Console.WriteLine("Message: " + ex.Message); } } } }
VB example
Imports System Imports System.Threading.Tasks Imports System.Collections.Generic Imports Independentsoft.Graph Imports Independentsoft.Graph.Calendars Namespace Sample Class Module1 Shared Sub Main(ByVal args As String()) Dim task = New Task(AddressOf Run) ' Start and wait for task to end. task.Start() Console.Read() End Sub Shared Async Sub Run() Try Dim client As GraphClient = New GraphClient() client.ClientId = "63333333-209e-454e-b7bd-55a4d201270f" client.Tenant = "independentsoft.onmicrosoft.com" client.Username = "info@independentsoft.onmicrosoft.com" client.Password = "password" Dim rooms As IList(Of Room) = Await client.GetRooms() For Each room As Room In rooms Console.WriteLine(room.Id) Console.WriteLine(room.DisplayName) Console.WriteLine(room.EmailAddress) Console.WriteLine(room.Capacity) Console.WriteLine(room.Building) Console.WriteLine(room.FloorNumber) Console.WriteLine(room.FloorLabel) If room.Address IsNot Nothing Then Console.WriteLine(room.Address.Street) Console.WriteLine(room.Address.PostalCode) Console.WriteLine(room.Address.City) Console.WriteLine(room.Address.Country) End If Next Catch ex As GraphException Console.WriteLine("Error: " + ex.Code) Console.WriteLine("Error: " + ex.Message) Console.Read() End Try End Sub End Class End Namespace
Need help? Ask our developers:
Name*
Email*
Message*