Exemplo n.º 1
0
        /// <summary>
        /// create a contact
        /// </summary>
        /// <returns>json body formatted as a string</returns>
        public static string CreateContactJson()
        {
            // create the contact object and set the root properties
            Contact contact = new Contact();
            contact.givenName = "Pavel";
            contact.surname = "Bansky";

            // create an offset with the current time
            DateTimeOffset dto = new DateTimeOffset();
            dto = DateTime.Now;

            // set the time values for the contact
            contact.birthday = dto;
            contact.createdDateTime = dto;
            contact.lastModifiedDateTime = dto;

            // create the email address list and emailaddress objects
            List<EmailAddress> emailAddresses = new List<EmailAddress>();
            EmailAddress email = new EmailAddress();

            // set the email object props and add it to the list
            email.address = "*****@*****.**";
            email.name = "Pavel Bansky";
            emailAddresses.Add(email);

            // set the contact emailaddresses
            contact.emailAddresses = emailAddresses;

            // create a phone number list, add it to the object and set it for the contact object
            List<string> businessPhoneNumbers = new List<string>();
            businessPhoneNumbers.Add("+1 732 555 0102");
            contact.businessPhones = businessPhoneNumbers;

            return SerializeJson(contact);
        }
Exemplo n.º 2
0
 /// <summary>
 /// this function does the work of creating the email address object
 /// and setting the necessary recipient email address values
 /// </summary>
 /// <param name="emailAddress">address property for Recipient</param>
 /// <param name="emailName">name property for the Recipient</param>
 /// <returns>Recipient object</returns>
 public static Recipient NewRecipient(string emailAddress, string emailName)
 {
     Recipient recip = new Recipient();
     EmailAddress email = new EmailAddress();
     email.address = emailAddress;
     email.name = emailName;
     recip.emailAddress = email;
     return recip;
 }
Exemplo n.º 3
0
        /// <summary>
        /// create a meeting with pre-defined values
        /// </summary>
        /// <returns>json formatted string body</returns>
        public static string CreateEventJson()
        {
            // create the event object
            Event evt = new Event();
            evt.subject = "Discuss the Calendar REST API";

            // create the body object
            Body body = new Body();
            body.contentType = "HTML";
            body.content = "I think it will meet our requirements!";
            evt.body = body;

            // create an offset with the current time
            DateTimeOffset dto = new DateTimeOffset();
            dto = DateTime.Now;

            // create the start time
            DateTimeTimeZone start = new DateTimeTimeZone();
            start.dateTime = dto;
            start.timeZone = "Pacific Standard Time";
            evt.start = start;

            // create the end time
            DateTimeTimeZone end = new DateTimeTimeZone();
            end.dateTime = dto.AddMinutes(30);
            end.timeZone = "Pacific Standard Time";
            evt.end = end;

            // set the other time values
            evt.createdDateTime = dto;
            evt.lastModifiedDateTime = dto;
            evt.originalStart = dto;
            evt.reminderMinutesBeforeStart = 15;

            // create the attendee list, attendee object and emailaddress object
            List<Attendee> attendeesList = new List<Attendee>();
            Attendee attendee = new Attendee();
            EmailAddress email = new EmailAddress();

            // set values for email and attendee
            email.address = "*****@*****.**";
            email.name = "Pavel Bansky";
            attendee.emailAddress = email;
            attendee.type = "Required";

            // add the attendee to the list and set the event object
            attendeesList.Add(attendee);
            evt.attendees = attendeesList;

            return SerializeJson(evt);
        }