public void createRsvpEditRsvpDeleteTest2()
 {
     var event_info = new facebookevent
     {
         description = "event description",
         end_date = System.DateTime.Now.AddDays(7),
         event_subtype = "1",
         event_type = "1",
         location = "location",
         venue = new location() { city = "chicago" },
         start_date = System.DateTime.Now.AddDays(1),
         host = "FB Samples",
         name = "create event test"
     };
     var actual = _api.Events.Create(event_info);
     Assert.IsTrue(actual > 0);
     var r1 = _api.Events.Rsvp(actual, "unsure");
     Assert.IsTrue(r1);
     event_info.name = "edited name";
     var e = _api.Events.Edit(actual, event_info);
     Assert.IsTrue(e);
     var r2 = _api.Events.Rsvp(actual, "declined");
     Assert.IsTrue(r2);
     var c = _api.Events.Cancel(actual, "test cancel");
     Assert.IsTrue(c);
 }
 public void createRsvpEditRsvpDeleteTest2()
 {
     var event_info = new facebookevent
     {
         description = "event description",
         end_date = System.DateTime.Now.AddDays(7),
         event_subtype = "1",
         event_type = "1",
         location = "location",
         venue = new location() { city = "chicago" },
         start_date = System.DateTime.Now.AddDays(1),
         host = "FB Samples",
         name = "create event test"
     };
     _api.Events.CreateAsync(event_info, Create2Completed, event_info);
 }
 private void LoadEvent(facebookevent facebookEvent)
 {
     pbEventPicture.Image = facebookEvent.picture;
     lblEvent.Text = facebookEvent.name;
     lblHostedBy.Text = facebookEvent.host;
     lblType.Text = facebookEvent.event_type;
     lblWhere.Text = facebookEvent.location;
     lblWhen.Text = facebookEvent.start_date.ToString();
 }
 /// <summary> 
 /// Constructor
 /// </summary>
 public EventListItem(facebookevent facebookEvent)
     : this()
 {
     _facebookEvent = facebookEvent;
     LoadEvent(facebookEvent);
 }
 /// <summary> 
 /// Constructor
 /// </summary>
 public EventItemSelectedEventArgs(facebookevent facebookEvent)
 {
     FacebookEvent = facebookEvent;
 }
 /// <summary>
 /// Creates an event on behalf of the user if the application has an active session; otherwise it creates an event on behalf of the application.
 /// </summary>
 /// <example>
 /// <code>
 /// Api api = new Api(new DesktopSession(Constants.ApplicationKey, Constants.ApplicationSecret, Constants.SessionSecret, Constants.SessionKey));
 /// facebookevent eventInfo = new facebookevent
 /// {
 ///     description = "event description",
 ///     end_date = DateTime.Now.AddDays(7),
 ///     event_subtype = "1",
 ///     event_type = "1",
 ///     location = "location",
 ///     venue = new location { city = "chicago" },
 ///     start_date = DateTime.Now.AddDays(1),
 ///     host = "Facebook Samples",
 ///     name = "test event"
 /// };
 /// var result = api.Events.Create(eventInfo);
 /// </code>
 /// </example>
 /// <param name="eventInfo">The event information. See the Facebook API Notes for information on what parameters to include in the object.</param>
 /// <returns>This method returns the identifier of the created event.</returns>
 /// <remarks>
 /// Create an event - You must pass the following parameters in the event_info array: 
 /// name 
 /// category 
 /// subcategory 
 /// location 
 /// start_time 
 /// end_time 
 /// The start_time and end_time are the times that were input by the event creator, converted to UTC after assuming that they were in Pacific time (Daylight Savings or Standard, depending on the date of the event), then converted into Unix epoch time. 
 ///
 /// Optionally, you can pass the following parameters in the event_info array: 
 ///    
 /// street 
 /// phone 
 /// email 
 /// host_id 
 /// host 
 /// desc 
 /// privacy_type 
 /// tagline 
 /// </remarks>
 public long Create(facebookevent eventInfo)
 {
     return Create(eventInfo, false, null, null);
 }
        private bool Edit(long eid, facebookevent event_info, bool isAsync, EditEventCallback callback, Object state)
        {
            var parameterList = new Dictionary<string, string> { { "method", "facebook.events.edit" } };
            Utilities.AddRequiredParameter(parameterList, "eid", eid);
            var dict = new Dictionary<string, string>
            {
                {"description", event_info.description},
                {"end_time", event_info.end_time.ToString()},
                {"category", event_info.event_type},
                {"subcategory", event_info.event_subtype},
                {"host", event_info.host},
                {"location", event_info.location},
                {"name", event_info.name},
                {"start_time", event_info.start_time.ToString()},
                {"tagline", event_info.tagline}
            };
            Utilities.AddJSONAssociativeArray(parameterList, "event_info", dict);

            if (isAsync)
            {
                SendRequestAsync<events_edit_response, bool>(parameterList, !string.IsNullOrEmpty(Session.SessionKey), new FacebookCallCompleted<bool>(callback), state);
                return true;
            }

            var response = SendRequest<events_edit_response>(parameterList, !string.IsNullOrEmpty(Session.SessionKey));
            return response == null ? false : response.TypedValue;
        }
        private long Create(facebookevent event_info, bool isAsync, CreateEventCallback callback, Object state)
        {
            var parameterList = new Dictionary<string, string> { { "method", "facebook.events.create" } };
            var dict = new Dictionary<string, string>
            {
                {"name", event_info.name},
                {"category", event_info.event_type},
                {"subcategory", event_info.event_subtype},
                {"host", event_info.host},
                {"location", event_info.location},
                {"city", event_info.venue.city},
                {"end_time", event_info.end_time.ToString()},
                {"start_time", event_info.start_time.ToString()}
            };
            if (event_info.venue.street != null)
            {
                dict.Add("street", event_info.venue.street);
            }
            if (event_info.description != null)
            {
                dict.Add("description", event_info.description);
            }
            if (event_info.privacy != null)
            {
                dict.Add("privacy_type", event_info.privacy);
            }
            if (event_info.tagline != null)
            {
                dict.Add("tagline", event_info.tagline);
            }

            Utilities.AddJSONAssociativeArray(parameterList, "event_info", dict);

            if (isAsync)
            {
                SendRequestAsync<events_create_response, long>(parameterList, !string.IsNullOrEmpty(Session.SessionKey), new FacebookCallCompleted<long>(callback), state);
                return 0;
            }

            var response = SendRequest<events_create_response>(parameterList, !string.IsNullOrEmpty(Session.SessionKey));
            return response == null ? 0 : response.TypedValue;
        }
 /// <summary>
 /// Edits an existing event. The application must be an admin of the event.
 /// </summary>
 /// <example>
 /// <code>
 /// private static void RunDemoAsync()
 /// {
 ///     Api api = new Api(new DesktopSession(Constants.ApplicationKey, Constants.ApplicationSecret, Constants.ApplicationSecret, Constants.SessionKey));
 ///     facebookevent eventInfo = new facebookevent
 ///     {
 ///         description = "event description 2",
 ///         end_date = DateTime.Now.AddDays(7),
 ///         event_subtype = "1",
 ///         event_type = "1",
 ///         location = "location",
 ///         venue = new location { city = "chicago" },
 ///         start_date = DateTime.Now.AddDays(1),
 ///         host = "Facebook Samples",
 ///         name = "test event"
 ///     };
 ///     api.Events.EditAsync(Constants.EventId, eventInfo, AsyncDemoCompleted, null);
 /// }
 ///
 /// private static void AsyncDemoCompleted(bool result, Object state, FacebookException e)
 /// {
 ///     var actual = result;
 /// }
 /// </code>
 /// </example>
 /// <param name="eid">The event ID.</param>
 /// <param name="eventInfo">The event information. See the Facebook API Notes for information on what parameters to include in the object.</param>
 /// <param name="callback">The AsyncCallback delegate</param>
 /// <param name="state">An object containing state information for this asynchronous request</param>        
 /// <returns>This method returns true if successful, or an error code otherwise.</returns>
 public void EditAsync(long eid, facebookevent eventInfo, EditEventCallback callback, Object state)
 {
     Edit(eid, eventInfo, true, callback, state);
 }
 /// <summary>
 /// Creates an event on behalf of the user if the application has an active session; otherwise it creates an event on behalf of the application.
 /// </summary>
 /// <example>
 /// <code>
 /// private static void RunDemoAsync()
 /// {
 ///     Api api = new Api(new DesktopSession(Constants.ApplicationKey, Constants.ApplicationSecret, Constants.ApplicationSecret, Constants.SessionKey));
 ///     facebookevent eventInfo = new facebookevent
 ///     {
 ///         description = "event description",
 ///         end_date = DateTime.Now.AddDays(7),
 ///         event_subtype = "1",
 ///         event_type = "1",
 ///         location = "location",
 ///         venue = new location { city = "chicago" },
 ///         start_date = DateTime.Now.AddDays(1),
 ///         host = "Facebook Samples",
 ///         name = "test event"
 ///     };
 ///     api.Events.CreateAsync(eventInfo, AsyncDemoCompleted, null);
 /// }
 ///
 /// private static void AsyncDemoCompleted(long result, Object state, FacebookException e)
 /// {
 ///     var actual = result;
 /// }
 /// </code>
 /// </example>
 /// <param name="eventInfo">The event information. See the Facebook API Notes for information on what parameters to include in the object.</param>
 /// <param name="callback">The AsyncCallback delegate</param>
 /// <param name="state">An object containing state information for this asynchronous request</param>        
 /// <returns>This method returns the identifier of the created event.</returns>
 /// <remarks>
 /// Create an event - You must pass the following parameters in the event_info array: 
 /// name 
 /// category 
 /// subcategory 
 /// location 
 /// start_time 
 /// end_time 
 /// The start_time and end_time are the times that were input by the event creator, converted to UTC after assuming that they were in Pacific time (Daylight Savings or Standard, depending on the date of the event), then converted into Unix epoch time. 
 ///
 /// Optionally, you can pass the following parameters in the event_info array: 
 ///    
 /// street 
 /// phone 
 /// email 
 /// host_id 
 /// host 
 /// desc 
 /// privacy_type 
 /// tagline 
 /// </remarks>
 public void CreateAsync(facebookevent eventInfo, CreateEventCallback callback, Object state)
 {
     Create(eventInfo, true, callback, state);
 }
 /// <summary>
 /// Edits an existing event. The application must be an admin of the event.
 /// </summary>
 /// <example>
 /// <code>
 /// Api api = new Api(new DesktopSession(Constants.ApplicationKey, Constants.ApplicationSecret, Constants.SessionSecret, Constants.SessionKey));
 /// facebookevent eventInfo = new facebookevent
 /// {
 ///     description = "event description 2",
 ///     end_date = DateTime.Now.AddDays(7),
 ///     event_subtype = "1",
 ///     event_type = "1",
 ///     location = "location",
 ///     venue = new location { city = "chicago" },
 ///     start_date = DateTime.Now.AddDays(1),
 ///     host = "Facebook Samples",
 ///     name = "test event"
 /// };
 /// var result = api.Events.Edit(Constants.EventId, eventInfo);
 /// </code>
 /// </example>
 /// <param name="eid">The event ID.</param>
 /// <param name="eventInfo">The event information. See the Facebook API Notes for information on what parameters to include in the object.</param>
 /// <returns>This method returns true if successful, or an error code otherwise.</returns>
 public bool Edit(long eid, facebookevent eventInfo)
 {
     return Edit(eid, eventInfo, false, null, null);
 }
        private void UnsureRsvp2Completed(bool result, object state, FacebookException e)
        {
            Assert.IsTrue(result);

            var event_info = new facebookevent
            {
                description = "event description",
                end_date = System.DateTime.Now.AddDays(7),
                event_subtype = "1",
                event_type = "1",
                location = "location",
                venue = new location() { city = "chicago" },
                start_date = System.DateTime.Now.AddDays(1),
                host = "FB Samples",
                name = "create event test"
            };

            event_info.name = "edited name";
            var eventId = (long)state;
            _api.Events.EditAsync(eventId, event_info, Edit2Completed, eventId);
        }