mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Some Blog service cleanup
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4043657
This commit is contained in:
@@ -17,15 +17,15 @@ namespace Orchard.Blogs.Services {
|
||||
|
||||
public BlogPost Get(Blog blog, string slug) {
|
||||
return _contentManager.Query<BlogPost, BlogPostRecord >()
|
||||
.Join<RoutableRecord>().Where(x => x.Slug == slug)
|
||||
.Join<CommonRecord>().Where(x => x.Container == blog.Record.ContentItemRecord)
|
||||
.Join<RoutableRecord>().Where(rr => rr.Slug == slug)
|
||||
.Join<CommonRecord>().Where(cr => cr.Container == blog.Record.ContentItemRecord)
|
||||
.List().FirstOrDefault();
|
||||
}
|
||||
|
||||
public IEnumerable<BlogPost> Get(Blog blog) {
|
||||
return _contentManager.Query<BlogPost, BlogPostRecord>()
|
||||
.Join<CommonRecord>().Where(x => x.Container == blog.Record.ContentItemRecord)
|
||||
.OrderByDescending(x=>x.CreatedUtc)
|
||||
.Join<CommonRecord>().Where(cr => cr.Container == blog.Record.ContentItemRecord)
|
||||
.OrderByDescending(cr => cr.CreatedUtc)
|
||||
.List();
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Common.Records;
|
||||
using Orchard.Data;
|
||||
using Orchard.Models;
|
||||
@@ -19,15 +18,16 @@ namespace Orchard.Blogs.Services {
|
||||
}
|
||||
|
||||
public Blog Get(string slug) {
|
||||
RoutableRecord record = _routableRepository.Get(r => r.ContentItemRecord.ContentType.Name == "blog" && r.Slug == slug);
|
||||
|
||||
return record != null ?_contentManager.Get<Blog>(record.Id) : null;
|
||||
return _contentManager.Query<Blog, BlogRecord>()
|
||||
.Join<RoutableRecord>().Where(rr => rr.Slug == slug)
|
||||
.List().FirstOrDefault();
|
||||
}
|
||||
|
||||
public IEnumerable<Blog> Get() {
|
||||
IEnumerable<RoutableRecord> records = _routableRepository.Fetch(rr => rr.ContentItemRecord.ContentType.Name == "blog", rr => rr.Asc(rr2 => rr2.Title));
|
||||
|
||||
return records.Select(rr => _contentManager.Get<Blog>(rr.Id));
|
||||
return _contentManager.Query<Blog, BlogRecord>()
|
||||
.Join<RoutableRecord>()
|
||||
.OrderBy(br => br.Title)
|
||||
.List();
|
||||
}
|
||||
|
||||
public void Delete(Blog blog) {
|
||||
|
Reference in New Issue
Block a user