diff --git a/Application/Entities.cs b/Application/Entities.cs
index d2f9315..897f448 100644
--- a/Application/Entities.cs
+++ b/Application/Entities.cs
@@ -1,6 +1,7 @@
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data.Entity.Infrastructure;
+using System.Linq;
namespace FeedCenter
{
@@ -48,6 +49,11 @@ namespace FeedCenter
}
}
+ public Category DefaultCategory
+ {
+ get { return _allCategories.First(c => c.IsDefault); }
+ }
+
#endregion
#region All feeds
diff --git a/Application/Feed.cs b/Application/Feed.cs
index e7dd4c0..6b58466 100644
--- a/Application/Feed.cs
+++ b/Application/Feed.cs
@@ -49,7 +49,7 @@ namespace FeedCenter
public FeedCenter.FeedReadResult LastReadResult { get; set; }
public System.DateTime LastUpdated { get; set; }
public FeedCenter.FeedItemComparison ItemComparison { get; set; }
- public System.Guid CategoryID { get; set; }
+ private System.Guid CategoryID { get; set; }
public FeedCenter.MultipleOpenAction MultipleOpenAction { get; set; }
public virtual Category Category { get; set; }
diff --git a/Application/Feeds/Feed.cs b/Application/Feeds/Feed.cs
index 1b6d54c..7e0b735 100644
--- a/Application/Feeds/Feed.cs
+++ b/Application/Feeds/Feed.cs
@@ -1,15 +1,13 @@
-using System.Text.RegularExpressions;
-using Common.Debug;
+using Common.Debug;
using Common.Xml;
using FeedCenter.FeedParsers;
using System;
using System.Diagnostics;
-using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
-using System.Windows.Data;
+using System.Text.RegularExpressions;
namespace FeedCenter
{
@@ -55,9 +53,9 @@ namespace FeedCenter
public partial class Feed
{
- public static Feed Create()
+ public static Feed Create(FeedCenterEntities database)
{
- return new Feed { ID = Guid.NewGuid() };
+ return new Feed { ID = Guid.NewGuid(), CategoryID = database.DefaultCategory.ID };
}
#region Event delegates
diff --git a/Application/MainWindow.xaml.cs b/Application/MainWindow.xaml.cs
index 350cc26..37d6484 100644
--- a/Application/MainWindow.xaml.cs
+++ b/Application/MainWindow.xaml.cs
@@ -780,9 +780,9 @@ namespace FeedCenter
private void HandleNewFeed(string feedUrl)
{
// Create and configure the new feed
- var feed = Feed.Create();
+ var feed = Feed.Create(_database);
feed.Source = feedUrl;
- feed.Category = _database.Categories.ToList().First(category => category.IsDefault);
+ feed.Category = _database.Categories.First(category => category.IsDefault);
// Read the feed for the first time
var feedReadResult = feed.Read(_database);
diff --git a/Application/Model.edmx b/Application/Model.edmx
index 73ae131..8feef63 100644
--- a/Application/Model.edmx
+++ b/Application/Model.edmx
@@ -180,7 +180,7 @@
-
+
diff --git a/Application/Options/FeedWindow.xaml b/Application/Options/FeedWindow.xaml
index 8878d76..9779e00 100644
--- a/Application/Options/FeedWindow.xaml
+++ b/Application/Options/FeedWindow.xaml
@@ -59,7 +59,7 @@
Name="categoryComboBox"
DisplayMemberPath="Name"
SelectedValuePath="ID"
- SelectedValue="{Binding Path=CategoryID}"
+ SelectedValue="{Binding Path=Category.ID}"
Grid.Row="2"
Margin="6" />
diff --git a/Application/Options/FeedsOptionsPanel.xaml.cs b/Application/Options/FeedsOptionsPanel.xaml.cs
index 81fc2ea..22bc1d9 100644
--- a/Application/Options/FeedsOptionsPanel.xaml.cs
+++ b/Application/Options/FeedsOptionsPanel.xaml.cs
@@ -61,7 +61,11 @@ namespace FeedCenter.Options
private void AddFeed()
{
- var feed = Feed.Create();
+ var feed = Feed.Create(Database);
+
+ var category = (Category) categoryListBox.SelectedItem;
+
+ feed.Category = category;
var feedWindow = new FeedWindow();
@@ -228,8 +232,8 @@ namespace FeedCenter.Options
while (xmlReader.NodeType != XmlNodeType.EndElement)
{
// Create a new feed
- var feed = Feed.Create();
- feed.Category = Database.Categories.ToList().First(c => c.IsDefault);
+ var feed = Feed.Create(Database);
+ feed.Category = Database.Categories.First(c => c.IsDefault);
// Loop over all attributes
while (xmlReader.MoveToNextAttribute())
@@ -379,7 +383,7 @@ namespace FeedCenter.Options
var feed = (Feed) e.Item;
- e.Accepted = (feed.Category == selectedCategory);
+ e.Accepted = (feed.Category.ID == selectedCategory.ID);
}
private void HandleTextBlockDrop(object sender, DragEventArgs e)
diff --git a/Application/Options/OptionsWindow.xaml.cs b/Application/Options/OptionsWindow.xaml.cs
index 9bc7e5e..613ef5a 100644
--- a/Application/Options/OptionsWindow.xaml.cs
+++ b/Application/Options/OptionsWindow.xaml.cs
@@ -120,6 +120,8 @@ namespace FeedCenter.Options
_database.SaveChanges();
Properties.Settings.Default.Save();
+ DialogResult = true;
+
// Close the window
Close();
}