public async Task<ActionResult> CreateMeeting(InputEvent InputEvent)
 {
     await Util.PostItemAsync<ExpandoObject>("events", FillEvent(InputEvent));
     return RedirectToAction("Index");
 }
        private ExpandoObject FillEvent(InputEvent InputEvent)
        {
            dynamic e = new ExpandoObject();
            e.Start = new DateTimeOffset(DateTime.Parse(InputEvent.Start));
            e.End = new DateTimeOffset(DateTime.Parse(InputEvent.End));
            e.StartTimeZone = InputEvent.Start_Time_Zone;
            e.EndTimeZone = InputEvent.End_Time_Zone;
            e.Subject = InputEvent.Subject;
            e.Organizer = new ExpandoObject();
            e.Organizer.EmailAddress = new ExpandoObject();
            e.Organizer.EmailAddress.Address = InputEvent.Organizer_Email;
            e.Organizer.EmailAddress.Name = InputEvent.Organizer_Email_Name;
            e.Attendees = new List<ExpandoObject>();
            e.Attendees.Add(e.Organizer);
            string [] attendeesEmail = InputEvent.Attendee_Email.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            string [] attendeeEmailName = InputEvent.Attendee_Email_Name.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < attendeesEmail.Length; i++)
            {
                dynamic attendee = new ExpandoObject();
                attendee.EmailAddress = new ExpandoObject();
                attendee.EmailAddress.Address = attendeesEmail[i];
                attendee.EmailAddress.Name = attendeeEmailName[i];
                e.Attendees.Add(attendee);
            }
            e.Body = new ExpandoObject();
            e.Body.Content = InputEvent.Content;
            e.Body.ContentType = InputEvent.Content_Type;
            e.Location = new ExpandoObject();
            e.Location.DisplayName = InputEvent.Location;
            if (!string.IsNullOrEmpty(InputEvent.Type))
            {
                e.Recurrence = new ExpandoObject();
                e.Recurrence.Pattern = new ExpandoObject();
                e.Recurrence.Pattern.Type = InputEvent.Type;
                e.Recurrence.Pattern.Interval = InputEvent.Interval;
                if (InputEvent.Type.Equals("Daily"))
                {
                    e.Recurrence.Pattern.FirstDayOfWeek = "Sunday";
                    e.Recurrence.Pattern.Month = 0;
                    e.Recurrence.Pattern.Index = "First";
                    e.Recurrence.Pattern.DayOfMonth = 0;
                }
                else if (InputEvent.Type.Equals("Weekly"))
                {
                    e.Recurrence.Pattern.FirstDayOfWeek = "Sunday";
                    e.Recurrence.Pattern.Month = 0;
                    e.Recurrence.Pattern.DayOfMonth = 0;
                    e.Recurrence.Pattern.Index = "First";
                    e.Recurrence.Pattern.DaysOfWeek = InputEvent.Days_of_Week.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                }
                else if (InputEvent.Type.Equals("RelativeMonthly"))
                {
                    e.Recurrence.Pattern.FirstDayOfWeek = "Sunday";
                    e.Recurrence.Pattern.Month = 0;
                    e.Recurrence.Pattern.DayOfMonth = 0;
                    e.Recurrence.Pattern.Index = InputEvent.Index;
                    e.Recurrence.Pattern.DaysOfWeek = InputEvent.Days_of_Week.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                }
                else if (InputEvent.Type.Equals("AbsoluteMonthly"))
                {
                    e.Recurrence.Pattern.FirstDayOfWeek = "Sunday";
                    e.Recurrence.Pattern.Index = "First";
                    e.Recurrence.Pattern.Month = 0;
                    e.Recurrence.Pattern.DayOfMonth = InputEvent.Day_Of_Month;
                }
                else if (InputEvent.Type.Equals("AbsoluteYearly"))
                {
                    e.Recurrence.Pattern.FirstDayOfWeek = "Sunday";
                    e.Recurrence.Pattern.Index = "First";
                    e.Recurrence.Pattern.Month = InputEvent.Month;
                    e.Recurrence.Pattern.DayOfMonth = InputEvent.Day_Of_Month;
                }
                else if (InputEvent.Type.Equals("RelativeYearly"))
                {
                    e.Recurrence.Pattern.FirstDayOfWeek = "Sunday";
                    e.Recurrence.Pattern.Month = InputEvent.Month;
                    e.Recurrence.Pattern.DayOfMonth = 0;
                    e.Recurrence.Pattern.Index = InputEvent.Index;
                    e.Recurrence.Pattern.DaysOfWeek = InputEvent.Days_of_Week.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                }

                e.Recurrence.Range = new ExpandoObject();
                e.Recurrence.Range.StartDate = InputEvent.StartDate;
                e.Recurrence.Range.Type = InputEvent.Range_Type;
                if (InputEvent.Range_Type.Equals("NoEnd"))
                {
                    e.Recurrence.Range.EndDate = "0001-01-01T00:00:00Z";
                    e.Recurrence.Range.NumberOfOccurrences = 0;
                }
                else if (InputEvent.Range_Type.Equals("Numbered"))
                {
                    e.Recurrence.Range.EndDate = "0001-01-01T00:00:00Z";
                    e.Recurrence.Range.NumberOfOccurrences = InputEvent.Number_Of_Occurences;
                }
                else if (InputEvent.Range_Type.Equals("EndDate"))
                {
                    e.Recurrence.Range.EndDate = InputEvent.EndDate;
                    e.Recurrence.Range.NumberOfOccurrences = 0;
                }               
            }
            return e;
        }