private StoryObj GetFullStoryObj(int id) { StoryObj so = new StoryObj(); try { FullStory fs = FullStoryFactory.GetFullStory(id); int commentCount = fs.TotalComments; string commentUrl = "https://news.ycombinator.com/item?id=" + id; var usercommentObjList = new List <UserCommentObj>(); var dictComments = fs.GetUserComments(); foreach (var kvp in dictComments) { UserCommentObj userCommentObj = new UserCommentObj() { User = kvp.Key, Comments = kvp.Value, StoryId = id }; usercommentObjList.Add(userCommentObj); } var keywordComments = fs.GetNamedObjects(20); List <KeywordCommentObj> keywordCommentObjList = new List <KeywordCommentObj>(); foreach (var kvp in keywordComments) { KeywordCommentObj keywordCommentObj = new KeywordCommentObj() { Keyword = kvp.Key, Comments = kvp.Value, StoryId = id }; keywordCommentObjList.Add(keywordCommentObj); } so = new StoryObj() { StoryId = id, StoryTitle = fs.title, Author = fs.author, StoryText = fs.text, Url = fs.url ?? commentUrl, CommentUrl = commentUrl, StoryComments = commentCount, AllUserComments = usercommentObjList, AllKeywordComments = keywordCommentObjList }; } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(so); }
private StoryObj GetFullStoryObj(int id) { StoryObj so = new StoryObj(); try { FullStory fs = FullStoryFactory.GetFullStory(id); int commentCount = fs.TotalComments; string commentUrl = "https://news.ycombinator.com/item?id=" + id; var usercommentObjList = new List<UserCommentObj>(); var dictComments = fs.GetUserComments(); foreach (var kvp in dictComments) { UserCommentObj userCommentObj = new UserCommentObj(){User = kvp.Key,Comments = kvp.Value,StoryId = id}; usercommentObjList.Add(userCommentObj); } var keywordComments = fs.GetNamedObjects(20); List<KeywordCommentObj> keywordCommentObjList = new List<KeywordCommentObj>(); foreach (var kvp in keywordComments) { KeywordCommentObj keywordCommentObj = new KeywordCommentObj(){Keyword = kvp.Key,Comments = kvp.Value,StoryId = id}; keywordCommentObjList.Add(keywordCommentObj); } so = new StoryObj() { StoryId = id, StoryTitle = fs.title, Author = fs.author, StoryText = fs.text, Url = fs.url ?? commentUrl, CommentUrl = commentUrl, StoryComments = commentCount,AllUserComments = usercommentObjList,AllKeywordComments = keywordCommentObjList}; } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return so; }