Beispiel #1
0
        async Task <int> FindAllAsync()
        {
            if (CalendarIDToUse == null)
            {
                await GetCalendarAsync();
            }
            if (CalendarIDToUse == null)
            {
                return(0);
            }
            var    Start  = DateTimeOffset.MinValue;
            var    End    = DateTimeOffset.MaxValue;
            var    ToFind = int.MaxValue;
            string Filter = "Start/DateTime+ge+'" + Start.ToString("u") + "'+and+End/DateTime+lt+'" + End.ToString("u") + "'";

            AllAppointments = await graphClient.Me.Calendars[CalendarIDToUse].Events.Request().Filter(Filter).Top(ToFind).GetAsync();

            return(AllAppointments.Count);
        }
Beispiel #2
0
        public async Task <(int, int)> DeleteAllEntrysAsync()
        {
            if (CalendarIDToUse == null)
            {
                await GetCalendarAsync();
            }
            if (AllAppointments == null)
            {
                try
                {
                    await FindAllAsync();

                    if (AllAppointments == null)
                    {
                        return(0, 0);
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    return(0, int.MaxValue);
                }
            }
            int DeleteCounter = 0;
            int ToDelete      = AllAppointments.Count;

            foreach (var item in AllAppointments)
            {
                try
                {
                    await graphClient.Me.Events[item.Id].Request().DeleteAsync();
                    DeleteCounter++;
                }
                catch (Exception ex)
                {
                }
            }
            await SaveAsync();

            AllAppointments = null;
            return(DeleteCounter, ToDelete);
        }