Fixed to category handling

This commit is contained in:
2014-12-15 16:05:45 -05:00
parent 722f134a4e
commit 75ba11fefd
8 changed files with 25 additions and 15 deletions

View File

@@ -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

View File

@@ -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; }

View File

@@ -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

View File

@@ -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);

View File

@@ -180,7 +180,7 @@
<Property Type="FeedCenterModel.FeedReadResult" Name="LastReadResult" Nullable="false" />
<Property Type="DateTime" Name="LastUpdated" Nullable="false" DefaultValue="1900-01-01 00:00:00.000Z" Precision="3" />
<Property Type="FeedCenterModel.FeedItemComparison" Name="ItemComparison" Nullable="false" />
<Property Type="Guid" Name="CategoryID" Nullable="false" />
<Property Type="Guid" Name="CategoryID" Nullable="false" a:GetterAccess="Private" xmlns:a="http://schemas.microsoft.com/ado/2006/04/codegeneration" a:SetterAccess="Private" />
<NavigationProperty Name="Category" Relationship="FeedCenterModel.FK_Feed_Category" FromRole="Feed" ToRole="Category" />
<NavigationProperty Name="Actions" Relationship="FeedCenterModel.FK_FeedAction_Feed" FromRole="Feed" ToRole="FeedAction" />
<NavigationProperty Name="Items" Relationship="FeedCenterModel.FK_FeedItem_Feed" FromRole="Feed" ToRole="FeedItem" />

View File

@@ -59,7 +59,7 @@
Name="categoryComboBox"
DisplayMemberPath="Name"
SelectedValuePath="ID"
SelectedValue="{Binding Path=CategoryID}"
SelectedValue="{Binding Path=Category.ID}"
Grid.Row="2"
Margin="6" />

View File

@@ -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)

View File

@@ -120,6 +120,8 @@ namespace FeedCenter.Options
_database.SaveChanges();
Properties.Settings.Default.Save();
DialogResult = true;
// Close the window
Close();
}