Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Graph .NET
>
Tutorial
> Update appointment - Reschedule for tomorrow
Update Start and End time to move the appointment for tomorrow.
C# example
using System; using System.Threading.Tasks; using System.Collections.Generic; using Independentsoft.Graph; using Independentsoft.Graph.Users; using Independentsoft.Graph.Calendars; using Independentsoft.Graph.QueryOptions; 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.ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; IsGreaterThanOrEqualTo condition1 = new IsGreaterThanOrEqualTo(EventPropertyName.StartTime, DateTime.Today.AddHours(10)); IsLessThanOrEqualTo condition2 = new IsLessThanOrEqualTo(EventPropertyName.StartTime, DateTime.Today.AddHours(12)); Query query = new Query(); query.Top = 999; query.Filter = new And(condition1, condition2); IList
appointments = await client.GetEvents(new UserId("info@independentsoft.onmicrosoft.com"), query); for (int i = 0; i < appointments.Count; i++) { Event tempAppointment = new Event(); tempAppointment.Id = appointments[i].Id; //important tempAppointment.Start = new DateTimeTimeZone(appointments[i].Start.Time.AddDays(1)); tempAppointment.End = new DateTimeTimeZone(appointments[i].End.Time.AddDays(1)); Event updatedAppointment = await client.UpdateEvent(tempAppointment, new UserId("info@independentsoft.onmicrosoft.com")); } } catch (GraphException ex) { Console.WriteLine("Error: " + ex.Code); Console.WriteLine("Message: " + ex.Message); Console.Read(); } } } }
VB example
Imports System Imports System.Threading.Tasks Imports System.Collections.Generic Imports Independentsoft.Graph Imports Independentsoft.Graph.Users Imports Independentsoft.Graph.Calendars Imports Independentsoft.Graph.QueryOptions 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.ClientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" Dim condition1 As IsGreaterThanOrEqualTo = New IsGreaterThanOrEqualTo(EventPropertyName.StartTime, DateTime.Today.AddHours(10)) Dim condition2 As IsLessThanOrEqualTo = New IsLessThanOrEqualTo(EventPropertyName.StartTime, DateTime.Today.AddHours(12)) Dim query As Query = New Query() query.Top = 999 query.Filter = New [And](condition1, condition2) Dim appointments As IList(Of [Event]) = Await client.GetEvents(new UserId("info@independentsoft.onmicrosoft.com"), query) Dim i As Integer For i = 0 To appointments.Count - 1 Step i + 1 Dim tempAppointment As [Event] = New [Event]() tempAppointment.Id = appointments(i).Id 'important tempAppointment.Start = New DateTimeTimeZone(appointments(i).Start.Time.AddDays(1)) tempAppointment.End = New DateTimeTimeZone(appointments(i).End.Time.AddDays(1)) Dim updatedAppointment As [Event] = Await client.UpdateEvent(tempAppointment, New UserId("info@independentsoft.onmicrosoft.com")) 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*