public static TopicReply TopicReplyWithJObject(JObject json, Topic topic) { // Get reply id string replyId = json["id"].ToString(); TopicReply reply = null; if (topic.ReplyCache.ContainsKey(replyId)) { reply = topic.ReplyCache[replyId]; } else { reply = new TopicReply(); reply.ResourceId = replyId; topic.ReplyCache[replyId] = reply; } // Parse user reply.Author = UserFactory.UserWithTopicJObject(json); reply.IsAdmin = (json["role"].ToString() == "admin"); reply.CreationDate = json["datecreate"].ToString().ToDateTime(); // Message reply.Message = json["message"]["_content"].ToString(); // Replies reply.CanDelete = (json["can_delete"].ToString() == "1"); return reply; }
private void OnTopicReplyAdded(object sender, AddTopicReplyEventArgs e) { FlickrGroup group = Cinderella.CinderellaCore.GroupCache[e.GroupId]; Topic topic = group.TopicCache[e.TopicId]; JObject rawJson = JObject.Parse(e.Response); string newReplyId = rawJson["reply"]["id"].ToString(); TopicReply newReply = new TopicReply(); newReply.ResourceId = newReplyId; newReply.Message = e.Message; newReply.Author = CurrentUser; newReply.CreationDate = DateTime.Now; topic.ReplyCache[newReplyId] = newReply; topic.Replies.Insert(0, newReply); topic.ReplyCount++; AddTopicReplyCompleteEventArgs evt = new AddTopicReplyCompleteEventArgs(); evt.SessionId = e.SessionId; evt.GroupId = group.ResourceId; evt.TopicId = topic.ResourceId; evt.newReply = newReply; AddTopicReplyCompleted.DispatchEvent(this, evt); }