Permalink
Browse files

The documents contained in a post should be persisted

  • Loading branch information...
1 parent 259e9d8 commit 073bd9513c311fa271e9d32b61aebd271eed3388 @jrusbatch committed Feb 8, 2013
Showing with 6 additions and 2 deletions.
  1. +3 −1 Core/Models/Post.cs
  2. +2 −0 DataAccess/MongoDB/MongoDbInitializer.cs
  3. +1 −1 DataAccess/MongoDB/MongoDbPostRepository.cs
View
@@ -1,11 +1,12 @@
using System;
using System.Collections.Generic;
+using System.Linq;
namespace Compilify.Models
{
public class Post : ICodeProject
{
- private readonly ISet<Document> documents;
+ private ICollection<Document> documents;
public Post()
{
@@ -44,6 +45,7 @@ TimeSpan ICodeProject.TimeoutPeriod
public IEnumerable<Document> Documents
{
get { return documents; }
+ set { documents = new HashSet<Document>(value ?? Enumerable.Empty<Document>()); }
}
public void AddDocument(string name, string text)
@@ -9,6 +9,8 @@ public static class MongoDbInitializer
{
public static void Initialize()
{
+ BsonClassMap.RegisterClassMap<Document>();
+
BsonClassMap.RegisterClassMap<Post>(x =>
{
x.AutoMap();
@@ -64,7 +64,7 @@ public Post Save(string slug, Post content)
content.Version = isNew ? 1 : GetLatestVersion(slug) + 1;
- db.GetCollection<Post>("posts").Save(content, SafeMode.True);
+ db.GetCollection<Post>("posts").Save(content, WriteConcern.Acknowledged);
return content;
}

0 comments on commit 073bd95

Please sign in to comment.