Exemple #1
0
        public HttpResponseMessage Create(TimeBlockCreateRequest createRequest)
        {
            if (createRequest == null)
            {
                ModelState.AddModelError("", "No data supplied!");
            }

            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            int UserId = User.Identity.GetId().Value;

            createRequest.UserId = UserId;
            int newId = calendarService.CreateTimeBlock(createRequest);

            Task.Run(() =>
            {
                UserConnectedCalendars userCalendar = exCalHelperService.CheckConnectedCalendars(UserId);
                if (userCalendar.hasGoogle)
                {
                    googleCalendarService.CreateEvent(UserId, newId, createRequest);
                }
                if (userCalendar.hasMicrosoft)
                {
                    msCalService.CreateEvent(UserId, newId, createRequest);
                }
            });

            return(Request.CreateResponse(HttpStatusCode.Created, new ItemResponse <int> {
                Item = newId
            }));
        }
Exemple #2
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            var path           = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "mycalendar_credentials.json");
            var googleCalendar = new GoogleCalendarService(path);
            var eventTitle     = EntryEventTitle.Text;
            var participants   = EntryParticipants.Text.Split(';');
            var eventDateTime  = new DateTime(DatePickerMeeting.Date.Year,
                                              DatePickerMeeting.Date.Month,
                                              DatePickerMeeting.Date.Day,
                                              TimePickerMeeting.Time.Hours,
                                              TimePickerMeeting.Time.Minutes,
                                              TimePickerMeeting.Time.Seconds
                                              );

            googleCalendar.CreateEvent(eventTitle, participants, eventDateTime, eventDateTime.AddHours(1));
        }