private void OnPhotoSetUpdated(object sender, EditPhotoSetEventArgs e) { PhotoSet photoSet = PhotoSetCache[e.SetId]; photoSet.Title = e.Title; photoSet.Description = e.Description; PhotoSetUpdatedEventArgs evt = new PhotoSetUpdatedEventArgs(); evt.PhotoSetId = e.SetId; PhotoSetUpdated.DispatchEvent(this, evt); }
public void EditPhotoSetAsync(string setId, string title, string description = null) { string timestamp = DateTimeUtils.GetTimestamp(); string nonce = Guid.NewGuid().ToString().Replace("-", null); Dictionary<string, string> paramDict = new Dictionary<string, string>(); paramDict["method"] = "flickr.photosets.editMeta"; paramDict["format"] = "json"; paramDict["nojsoncallback"] = "1"; paramDict["oauth_consumer_key"] = consumerKey; paramDict["oauth_nonce"] = nonce; paramDict["oauth_signature_method"] = "HMAC-SHA1"; paramDict["oauth_timestamp"] = timestamp; paramDict["oauth_token"] = AccessToken; paramDict["oauth_version"] = "1.0"; paramDict["photoset_id"] = setId; paramDict["title"] = title; if (description != null) { paramDict["description"] = description; } string signature = OAuthCalculateSignature("POST", "https://api.flickr.com/services/rest/", paramDict, AccessTokenSecret); paramDict["oauth_signature"] = signature; DispatchPostRequest("POST", "https://api.flickr.com/services/rest/", paramDict, (response) => { bool success = true; string errorMessage = ""; try { JObject json = JObject.Parse(response); string status = json["stat"].ToString(); if (status != "ok") { success = false; errorMessage = json["message"].ToString(); } } catch (Exception e) { Debug.WriteLine(e.Message); success = false; } if (!success) { EditPhotoSetExceptionEventArgs exceptionArgs = new EditPhotoSetExceptionEventArgs(); exceptionArgs.SetId = setId; exceptionArgs.ErrorMessage = errorMessage; PhotoSetEditException.DispatchEvent(this, exceptionArgs); } else { EditPhotoSetEventArgs args = new EditPhotoSetEventArgs(); args.SetId = setId; args.Title = title; args.Description = description; PhotoSetEdited.DispatchEvent(this, args); } }, (ex) => { EditPhotoSetExceptionEventArgs exceptionArgs = new EditPhotoSetExceptionEventArgs(); exceptionArgs.SetId = setId; exceptionArgs.ErrorMessage = "Unknown network error"; PhotoSetEditException.DispatchEvent(this, exceptionArgs); }); }