public static PhotoComment PhotoCommentWithJObject(JObject json, Photo photo) { // Get comment id string commentId = json["id"].ToString(); PhotoComment comment = null; if (photo.CommentCache.ContainsKey(commentId)) { comment = photo.CommentCache[commentId]; } else { comment = new PhotoComment(); comment.ResourceId = commentId; photo.CommentCache[commentId] = comment; } // Parse user comment.Author = UserFactory.UserWithPhotoCommentJObject(json); comment.CreationDate = json["datecreate"].ToString().ToDateTime(); // Content comment.Message = json["_content"].ToString(); return comment; }
private void OnPhotoCommentAdded(object sender, AddCommentEventArgs e) { Photo photo = Cinderella.CinderellaCore.PhotoCache[e.PhotoId]; JObject rawJson = JObject.Parse(e.Response); string newCommentId = rawJson["comment"]["id"].ToString(); PhotoComment newComment = new PhotoComment(); newComment.ResourceId = newCommentId; newComment.Message = e.Message; newComment.Author = CurrentUser; newComment.CreationDate = DateTime.Now; photo.CommentCache[newCommentId] = newComment; photo.Comments.Insert(0, newComment); photo.CommentCount++; AddPhotoCommentCompleteEventArgs evt = new AddPhotoCommentCompleteEventArgs(); evt.SessionId = e.SessionId; evt.PhotoId = photo.ResourceId; evt.NewComment = newComment; AddPhotoCommentCompleted.DispatchEvent(this, evt); }