diff options
author | Aryadev Chavali <aryadevchavali1@gmail.com> | 2019-02-08 11:00:25 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadevchavali1@gmail.com> | 2019-02-08 11:00:25 +0000 |
commit | 073a9e47253dc876405180f8fab802678fdad2f3 (patch) | |
tree | c235fcebd7af8ef65cadcba528020f5c8aacfcb2 /Main/Program.cs | |
parent | c40ef143f420ccfb46cddc5f0dbe9e117f4f0b94 (diff) | |
download | newsaggregator-073a9e47253dc876405180f8fab802678fdad2f3.tar.gz newsaggregator-073a9e47253dc876405180f8fab802678fdad2f3.tar.bz2 newsaggregator-073a9e47253dc876405180f8fab802678fdad2f3.zip |
Added database handler to test whether database connection works
Diffstat (limited to 'Main/Program.cs')
-rw-r--r-- | Main/Program.cs | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/Main/Program.cs b/Main/Program.cs index 48897d6..46e2bae 100644 --- a/Main/Program.cs +++ b/Main/Program.cs @@ -10,21 +10,27 @@ using Aggregator.Parser; namespace Main {
internal static class Program {
private static async Task Main(string[] args) {
- // List<Config> configs = new List<Config>() {
- // new Config() {
- // Source = "BBC",
- // Title = 0,
- // Description = 1,
- // ArticleLink = 2,
- // ImageLink = 5,
- // PublishDate = 4
- // }
- // };
- // string[] xmls = new [] {
- // await Download.DownloadXML("http://feeds.bbci.co.uk/news/rss.xml")
- // };
- // List<Article> articles = ParserService.ParseMultiple(xmls, configs).ToList();
- // Console.WriteLine(articles.Count);
+ List<Config> configs = new List<Config>() {
+ new Config() {
+ Source = "BBC",
+ Title = 0,
+ Description = 1,
+ ArticleLink = 2,
+ ImageLink = 5,
+ PublishDate = 4
+ }
+ };
+ string[] xmls = new [] {
+ await Download.DownloadXML("http://feeds.bbci.co.uk/news/rss.xml")
+ };
+ List<Article> articles = ParserService.ParseMultiple(xmls, configs).ToList();
+ Console.WriteLine(articles.Count);
+
+ using (var db = new DatabaseContext()) {
+ await db.Articles.AddAsync(articles[0]);
+ int records = await db.SaveChangesAsync();
+ Console.WriteLine($"Wrote {records} records!");
+ }
}
}
}
|