Basic comment building
This commit is contained in:
38
Program.cs
38
Program.cs
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
//using OllamaSharp;
|
||||
using OllamaSharp;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using SaltMiner.Data;
|
||||
using System.Formats.Tar;
|
||||
|
||||
|
||||
namespace SaltMiner
|
||||
@@ -10,14 +12,44 @@ namespace SaltMiner
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
/*
|
||||
|
||||
var configurationBuilder = new ConfigurationBuilder();
|
||||
|
||||
configurationBuilder.SetBasePath(System.IO.Directory.GetCurrentDirectory());
|
||||
configurationBuilder.AddJsonFile(path: "appSettings.json", optional: false, reloadOnChange: true);
|
||||
|
||||
var config = configurationBuilder.Build();
|
||||
*/
|
||||
|
||||
String linkID = "3yyupi";
|
||||
|
||||
using(var ctx = new RedditContext())
|
||||
{
|
||||
var link = ctx.Links.Where(l => l.LinkId == linkID).First();
|
||||
var comments = ctx.Comments.Where(c => c.LinkId == linkID).ToList();
|
||||
Submission sub = new Submission();
|
||||
sub.Title = link.Title;
|
||||
sub.Author = link.Author;
|
||||
sub.Link = link.Url;
|
||||
sub.Body = link.SelfText;
|
||||
foreach(var comment in comments.Where(c => c.ParentId == null))
|
||||
{ //top level
|
||||
sub.Replies.Add(PopulateComments(sub, comments, comment));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static Comments PopulateComments(Submission sub, IEnumerable<Data.Comment> comments, Data.Comment targetComment)
|
||||
{
|
||||
Comments comment = new Comments();
|
||||
comment.Author = targetComment.Author;
|
||||
comment.Body = targetComment.Body;
|
||||
foreach(var reply in comments.Where(c => c.ParentId == targetComment.CommentId))
|
||||
{
|
||||
comment.Replies.Add(PopulateComments(sub, comments, reply));
|
||||
}
|
||||
return comment;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user