--HG--
branch : dev
This commit is contained in:
Bertrand Le Roy
2010-02-24 10:23:20 -08:00
7 changed files with 19 additions and 10 deletions

View File

@@ -5,6 +5,7 @@ using JetBrains.Annotations;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;
using Orchard.Core.Common.Records; using Orchard.Core.Common.Records;
using Orchard.Data; using Orchard.Data;
using Orchard.Blogs.Controllers;
namespace Orchard.Blogs.Models { namespace Orchard.Blogs.Models {
[UsedImplicitly] [UsedImplicitly]
@@ -27,7 +28,7 @@ namespace Orchard.Blogs.Models {
//INFO: (erikpo) Get all blog posts for the current blog //INFO: (erikpo) Get all blog posts for the current blog
var postsQuery = var postsQuery =
from bpr in commonRepository.Table from bpr in commonRepository.Table
where bpr.ContentItemRecord.ContentType.Name == "blogpost" && bpr.Container.Id == blogPost.Blog.Record.Id where bpr.ContentItemRecord.ContentType.Name == BlogPostDriver.ContentType.Name && bpr.Container.Id == blogPost.Blog.Record.Id
orderby bpr.PublishedUtc orderby bpr.PublishedUtc
select bpr; select bpr;

View File

@@ -101,7 +101,7 @@ namespace Orchard.Comments.Services {
} }
public Comment CreateComment(CreateCommentContext context) { public Comment CreateComment(CreateCommentContext context) {
var comment = _contentManager.Create<Comment>("comment"); var comment = _contentManager.Create<Comment>(CommentDriver.ContentType.Name);
comment.Record.Author = context.Author; comment.Record.Author = context.Author;
comment.Record.CommentDateUtc = _clock.UtcNow; comment.Record.CommentDateUtc = _clock.UtcNow;

View File

@@ -108,7 +108,7 @@ namespace Orchard.Pages.Controllers {
if (!Services.Authorizer.Authorize(Permissions.EditPages, T("Not allowed to create a page"))) if (!Services.Authorizer.Authorize(Permissions.EditPages, T("Not allowed to create a page")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
var page = Services.ContentManager.BuildEditorModel(Services.ContentManager.New<Page>("page")); var page = Services.ContentManager.BuildEditorModel(Services.ContentManager.New<Page>(PageDriver.ContentType.Name));
var model = new PageCreateViewModel { var model = new PageCreateViewModel {
Page = page Page = page
@@ -123,7 +123,7 @@ namespace Orchard.Pages.Controllers {
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
// Validate form input // Validate form input
var page = Services.ContentManager.New<Page>("page"); var page = Services.ContentManager.New<Page>(PageDriver.ContentType.Name);
model.Page = Services.ContentManager.UpdateEditorModel(page, this); model.Page = Services.ContentManager.UpdateEditorModel(page, this);
if (!ModelState.IsValid) { if (!ModelState.IsValid) {

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Orchard.ContentManagement.Records; using Orchard.ContentManagement.Records;
using Orchard.Pages.Controllers;
using Orchard.Pages.Models; using Orchard.Pages.Models;
using Orchard.Core.Common.Records; using Orchard.Core.Common.Records;
using Orchard.ContentManagement; using Orchard.ContentManagement;
@@ -42,7 +43,7 @@ namespace Orchard.Pages.Services {
public Page Get(string slug) { public Page Get(string slug) {
return return
_contentManager.Query("page").Join<RoutableRecord>().Where(rr => rr.Slug == slug).List().FirstOrDefault _contentManager.Query(PageDriver.ContentType.Name).Join<RoutableRecord>().Where(rr => rr.Slug == slug).List().FirstOrDefault
().As<Page>(); ().As<Page>();
} }
@@ -52,7 +53,7 @@ namespace Orchard.Pages.Services {
public Page GetLatest(string slug) { public Page GetLatest(string slug) {
return return
_contentManager.Query(VersionOptions.Latest, "page").Join<RoutableRecord>().Where(rr => rr.Slug == slug) _contentManager.Query(VersionOptions.Latest, PageDriver.ContentType.Name).Join<RoutableRecord>().Where(rr => rr.Slug == slug)
.Slice(0, 1).FirstOrDefault().As<Page>(); .Slice(0, 1).FirstOrDefault().As<Page>();
} }

View File

@@ -56,7 +56,7 @@ namespace Orchard.Sandbox.Controllers {
return RedirectToAction("index"); return RedirectToAction("index");
} }
var page = Services.ContentManager.Create<SandboxPage>("sandboxpage", item => { var page = Services.ContentManager.Create<SandboxPage>(SandboxPageDriver.ContentType.Name, item => {
item.Record.Name = model.Name; item.Record.Name = model.Name;
}); });
return RedirectToAction("show", new { page.ContentItem.Id }); return RedirectToAction("show", new { page.ContentItem.Id });

View File

@@ -7,6 +7,7 @@ using Orchard.Data;
using Orchard.Logging; using Orchard.Logging;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.Security; using Orchard.Security;
using Orchard.Users.Controllers;
using Orchard.Users.Models; using Orchard.Users.Models;
namespace Orchard.Users.Services { namespace Orchard.Users.Services {
@@ -30,8 +31,9 @@ namespace Orchard.Users.Services {
public IUser CreateUser(CreateUserParams createUserParams) { public IUser CreateUser(CreateUserParams createUserParams) {
Logger.Information("CreateUser {0} {1}", createUserParams.Username, createUserParams.Email); Logger.Information("CreateUser {0} {1}", createUserParams.Username, createUserParams.Email);
return _contentManager.Create<User>("user", init => { return _contentManager.Create<User>(UserDriver.ContentType.Name, init =>
{
init.Record.UserName = createUserParams.Username; init.Record.UserName = createUserParams.Username;
init.Record.Email = createUserParams.Email; init.Record.Email = createUserParams.Email;
SetPassword(init.Record, createUserParams.Password); SetPassword(init.Record, createUserParams.Password);

View File

@@ -28,7 +28,12 @@ namespace Orchard.Storage {
public IEnumerable<IStorageFolder> ListFolders(string path) { public IEnumerable<IStorageFolder> ListFolders(string path) {
if (!Directory.Exists(path)) { if (!Directory.Exists(path)) {
throw new ArgumentException("Directory " + path + " does not exist"); try {
Directory.CreateDirectory(path);
}
catch (Exception ex) {
throw new ArgumentException(string.Format("The folder could not be created at path: {0}. {1}",path,ex));
}
} }
return new DirectoryInfo(path) return new DirectoryInfo(path)