Exemple #1
0
        public async Task <bool> AddAppointment(MyAppointmentType appointment)
        {
            var eventStore = new EKEventStore();
            var granted    = await eventStore.RequestAccessAsync(EKEntityType.Event);

            if (granted.Item1)
            {
                EKEvent newEvent = EKEvent.FromStore(eventStore);
                newEvent.StartDate = DateTimeToNSDate(appointment.ExpireDate);
                newEvent.EndDate   = DateTimeToNSDate(appointment.ExpireDate.AddHours(1));
                newEvent.Title     = appointment.Title; newEvent.Notes = appointment.WhereWhen;
                newEvent.Calendar  = eventStore.DefaultCalendarForNewEvents;
                return(eventStore.SaveEvent(newEvent, EKSpan.ThisEvent, out NSError e));
            }
            return(false);
        }
Exemple #2
0
        public Task <bool> AddAppointment(MyAppointmentType appointment)
        {
            var intent = new Intent(Intent.ActionInsert);

            intent.PutExtra(CalendarContract.Events.InterfaceConsts.Title, appointment.Title);
            intent.PutExtra(CalendarContract.Events.InterfaceConsts.Description, appointment.WhereWhen + " " + appointment.Description);
            intent.PutExtra(CalendarContract.Events.InterfaceConsts.Dtstart, GetDateTimeMS(appointment.ExpireDate));
            intent.PutExtra(CalendarContract.Events.InterfaceConsts.Dtend, GetDateTimeMS(appointment.ExpireDate.AddHours(1)));
            intent.PutExtra(CalendarContract.ExtraEventBeginTime, GetDateTimeMS(appointment.ExpireDate));
            intent.PutExtra(CalendarContract.ExtraEventEndTime, GetDateTimeMS(appointment.ExpireDate.AddHours(1)));
            intent.PutExtra(CalendarContract.Events.InterfaceConsts.EventTimezone, "UTC");
            intent.PutExtra(CalendarContract.Events.InterfaceConsts.EventEndTimezone, "UTC");
            intent.SetData(CalendarContract.Events.ContentUri);
            CrossCurrentActivity.Current.Activity.StartActivity(intent);

            return(Task.FromResult(true));
        }