mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Refining extension methods. Adding a streamlined content manager creation method.
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4041639
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
using Orchard.Models;
|
||||
|
||||
namespace Orchard.Blogs.Models {
|
||||
public class Blog : ContentPartForRecord<BlogRecord> {
|
||||
public class Blog : ContentPart<BlogRecord> {
|
||||
public string Name { get { return Record.Name; } }
|
||||
public string Slug { get { return Record.Slug; } }
|
||||
public bool Enabled { get { return Record.Enabled; } }
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using Orchard.Models;
|
||||
|
||||
namespace Orchard.Blogs.Models {
|
||||
public class BlogPost : ContentPartForRecord<BlogPostRecord> {
|
||||
public class BlogPost : ContentPart<BlogPostRecord> {
|
||||
public string BlogSlug { get { return Record.Blog.Slug; } }
|
||||
public string Title { get { return Record.Title; } }
|
||||
public string Slug { get { return Record.Slug; } }
|
||||
|
@@ -5,7 +5,7 @@ namespace Orchard.Blogs.Models {
|
||||
public class BlogPostProvider : ContentProvider {
|
||||
public BlogPostProvider(IRepository<BlogPostRecord> repository) {
|
||||
Filters.Add(new ActivatingFilter<BlogPost>("blogpost"));
|
||||
Filters.Add(new StorageFilterForRecord<BlogPostRecord>(repository));
|
||||
Filters.Add(new StorageFilter<BlogPostRecord>(repository));
|
||||
}
|
||||
}
|
||||
}
|
@@ -5,7 +5,7 @@ namespace Orchard.Blogs.Models {
|
||||
public class BlogProvider : ContentProvider {
|
||||
public BlogProvider(IRepository<BlogRecord> repository) {
|
||||
Filters.Add(new ActivatingFilter<Blog>("blog"));
|
||||
Filters.Add(new StorageFilterForRecord<BlogRecord>(repository));
|
||||
Filters.Add(new StorageFilter<BlogRecord>(repository));
|
||||
}
|
||||
}
|
||||
}
|
@@ -20,20 +20,17 @@ namespace Orchard.Blogs.Services {
|
||||
}
|
||||
|
||||
public IEnumerable<Blog> Get() {
|
||||
IEnumerable<BlogRecord> blogs =_repository.Fetch(br => br.Enabled, br => br.Asc(br2 => br2.Name));
|
||||
IEnumerable<BlogRecord> blogs = _repository.Fetch(br => br.Enabled, br => br.Asc(br2 => br2.Name));
|
||||
|
||||
return blogs.Select(br => _contentManager.Get(br.Id).As<Blog>());
|
||||
return blogs.Select(br => _contentManager.Get<Blog>(br.Id));
|
||||
}
|
||||
|
||||
public Blog CreateBlog(CreateBlogParams parameters) {
|
||||
BlogRecord record = new BlogRecord() {Name = parameters.Name, Slug = parameters.Slug, Enabled = parameters.Enabled};
|
||||
|
||||
//TODO: (erikpo) Need an extension method or something for this default behavior
|
||||
Blog blog = _contentManager.New<Blog>("blog");
|
||||
blog.Record = record;
|
||||
_contentManager.Create(blog);
|
||||
|
||||
return blog;
|
||||
return _contentManager.Create<Blog>("blog", init => {
|
||||
init.Record.Name = parameters.Name;
|
||||
init.Record.Slug = parameters.Slug;
|
||||
init.Record.Enabled = parameters.Enabled;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user