Moving create, update, delete actions from BlogController and BlogPostController into BlogAdminController and BlogPostController for consistency.

--HG--
extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045254
This commit is contained in:
ErikPorter
2010-01-11 22:07:03 +00:00
parent 88e797a9b1
commit 418e975ab1
12 changed files with 323 additions and 316 deletions

View File

@@ -1,19 +1,130 @@
using System.Linq;
using System.Web.Mvc;
using Orchard.Blogs.Extensions;
using Orchard.Blogs.Models;
using Orchard.Blogs.Services;
using Orchard.Blogs.ViewModels;
using Orchard.ContentManagement;
using Orchard.Data;
using Orchard.Localization;
using Orchard.Mvc.Results;
using Orchard.Security;
using Orchard.UI.Notify;
namespace Orchard.Blogs.Controllers {
[ValidateInput(false)]
public class BlogAdminController : Controller {
public class BlogAdminController : Controller, IUpdateModel {
private readonly IOrchardServices _services;
private readonly IBlogService _blogService;
private readonly ISessionLocator _sessionLocator;
private readonly IAuthorizer _authorizer;
private readonly INotifier _notifier;
public BlogAdminController(IOrchardServices services, IBlogService blogService) {
public BlogAdminController(IOrchardServices services, IBlogService blogService, ISessionLocator sessionLocator, IAuthorizer authorizer, INotifier notifier) {
_services = services;
_blogService = blogService;
_sessionLocator = sessionLocator;
_authorizer = authorizer;
_notifier = notifier;
T = NullLocalizer.Instance;
}
private Localizer T { get; set; }
public ActionResult Create() {
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
if (!_authorizer.Authorize(Permissions.CreateBlog, T("Not allowed to create blogs")))
return new HttpUnauthorizedResult();
Blog blog = _services.ContentManager.New<Blog>("blog");
if (blog == null)
return new NotFoundResult();
var model = new CreateBlogViewModel {
Blog = _services.ContentManager.BuildEditorModel(blog)
};
return View(model);
}
[HttpPost]
public ActionResult Create(CreateBlogViewModel model) {
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
if (!_authorizer.Authorize(Permissions.CreateBlog, T("Couldn't create blog")))
return new HttpUnauthorizedResult();
model.Blog = _services.ContentManager.UpdateEditorModel(_services.ContentManager.New<Blog>("blog"), this);
if (!ModelState.IsValid)
return View(model);
_services.ContentManager.Create(model.Blog.Item.ContentItem);
//TEMP: (erikpo) ensure information has committed for this record
var session = _sessionLocator.For(typeof(BlogRecord));
session.Flush();
return Redirect(Url.BlogForAdmin(model.Blog.Item.Slug));
}
public ActionResult Edit(string blogSlug) {
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
if (!_authorizer.Authorize(Permissions.ModifyBlog, T("Not allowed to edit blog")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
Blog blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
var model = new BlogEditViewModel {
Blog = _services.ContentManager.BuildEditorModel(blog)
};
return View(model);
}
[HttpPost]
public ActionResult Edit(string blogSlug, FormCollection input) {
if (!_authorizer.Authorize(Permissions.ModifyBlog, T("Couldn't edit blog")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
Blog blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
var model = new BlogEditViewModel {
Blog = _services.ContentManager.UpdateEditorModel(blog, this)
};
if (!ModelState.IsValid)
return View(model);
_notifier.Information(T("Blog information updated"));
return Redirect(Url.BlogsForAdmin());
}
//[HttpPost] <- todo: (heskew) make all add/edit/remove POST only and verify the AntiForgeryToken
public ActionResult Delete(string blogSlug) {
if (!_authorizer.Authorize(Permissions.DeleteBlog, T("Couldn't delete blog")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
Blog blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
_blogService.Delete(blog);
_notifier.Information(T("Blog was successfully deleted"));
return Redirect(Url.BlogsForAdmin());
}
public ActionResult List() {
@@ -39,5 +150,13 @@ namespace Orchard.Blogs.Controllers {
return View(model);
}
bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
return TryUpdateModel(model, prefix, includeProperties, excludeProperties);
}
void IUpdateModel.AddModelError(string key, LocalizedString errorMessage) {
ModelState.AddModelError(key, errorMessage.ToString());
}
}
}

View File

@@ -1,36 +1,24 @@
using System.Linq;
using System.Web.Mvc;
using Orchard.Blogs.Extensions;
using Orchard.Blogs.Models;
using Orchard.Blogs.Services;
using Orchard.Blogs.ViewModels;
using Orchard.Data;
using Orchard.Localization;
using Orchard.ContentManagement;
using Orchard.Mvc.Results;
using Orchard.Security;
using Orchard.UI.Notify;
namespace Orchard.Blogs.Controllers {
[ValidateInput(false)]
public class BlogController : Controller, IUpdateModel {
public class BlogController : Controller {
private readonly IOrchardServices _services;
private readonly ISessionLocator _sessionLocator;
private readonly IAuthorizer _authorizer;
private readonly INotifier _notifier;
private readonly IBlogService _blogService;
public BlogController(IOrchardServices services, ISessionLocator sessionLocator, IAuthorizer authorizer, INotifier notifier, IBlogService blogService) {
_services = services;
_sessionLocator = sessionLocator;
_authorizer = authorizer;
_notifier = notifier;
_blogService = blogService;
T = NullLocalizer.Instance;
}
private Localizer T { get; set; }
public ActionResult List() {
var model = new BlogsViewModel {
Blogs = _blogService.Get().Select(b => _services.ContentManager.BuildDisplayModel(b, "Summary"))
@@ -52,109 +40,5 @@ namespace Orchard.Blogs.Controllers {
return View(model);
}
public ActionResult Create() {
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
if (!_authorizer.Authorize(Permissions.CreateBlog, T("Not allowed to create blogs")))
return new HttpUnauthorizedResult();
Blog blog = _services.ContentManager.New<Blog>("blog");
if (blog == null)
return new NotFoundResult();
var model = new CreateBlogViewModel {
Blog = _services.ContentManager.BuildEditorModel(blog)
};
return View(model);
}
[HttpPost]
public ActionResult Create(CreateBlogViewModel model) {
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
if (!_authorizer.Authorize(Permissions.CreateBlog, T("Couldn't create blog")))
return new HttpUnauthorizedResult();
model.Blog = _services.ContentManager.UpdateEditorModel(_services.ContentManager.New<Blog>("blog"), this);
if (!ModelState.IsValid)
return View(model);
_services.ContentManager.Create(model.Blog.Item.ContentItem);
//TEMP: (erikpo) ensure information has committed for this record
var session = _sessionLocator.For(typeof(BlogRecord));
session.Flush();
return Redirect(Url.BlogForAdmin(model.Blog.Item.Slug));
}
public ActionResult Edit(string blogSlug) {
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
if (!_authorizer.Authorize(Permissions.ModifyBlog, T("Not allowed to edit blog")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
Blog blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
var model = new BlogEditViewModel {
Blog = _services.ContentManager.BuildEditorModel(blog)
};
return View(model);
}
[HttpPost]
public ActionResult Edit(string blogSlug, FormCollection input) {
if (!_authorizer.Authorize(Permissions.ModifyBlog, T("Couldn't edit blog")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
Blog blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
var model = new BlogEditViewModel {
Blog = _services.ContentManager.UpdateEditorModel(blog, this)
};
if (!ModelState.IsValid)
return View(model);
_notifier.Information(T("Blog information updated"));
return Redirect(Url.BlogsForAdmin());
}
//[HttpPost] <- todo: (heskew) make all add/edit/remove POST only and verify the AntiForgeryToken
public ActionResult Delete(string blogSlug) {
if (!_authorizer.Authorize(Permissions.DeleteBlog, T("Couldn't delete blog")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
Blog blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
_blogService.Delete(blog);
_notifier.Information(T("Blog was successfully deleted"));
return Redirect(Url.BlogsForAdmin());
}
bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
return TryUpdateModel(model, prefix, includeProperties, excludeProperties);
}
void IUpdateModel.AddModelError(string key, LocalizedString errorMessage) {
ModelState.AddModelError(key, errorMessage.ToString());
}
}
}

View File

@@ -0,0 +1,179 @@
using System.Web.Mvc;
using Orchard.Blogs.Extensions;
using Orchard.Blogs.Models;
using Orchard.Blogs.Services;
using Orchard.Blogs.ViewModels;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Records;
using Orchard.Data;
using Orchard.Localization;
using Orchard.Mvc.Results;
using Orchard.UI.Notify;
namespace Orchard.Blogs.Controllers {
public class BlogPostAdminController : Controller, IUpdateModel {
private readonly IOrchardServices _services;
private readonly IBlogService _blogService;
private readonly IBlogPostService _blogPostService;
private readonly ISessionLocator _sessionLocator;
public BlogPostAdminController(IOrchardServices services, IBlogService blogService, IBlogPostService blogPostService, ISessionLocator sessionLocator) {
_services = services;
_blogService = blogService;
_blogPostService = blogPostService;
_sessionLocator = sessionLocator;
T = NullLocalizer.Instance;
}
private Localizer T { get; set; }
public ActionResult Create(string blogSlug) {
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
if (!_services.Authorizer.Authorize(Permissions.CreatePost, T("Not allowed to create blog post")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
Blog blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
var blogPost = _services.ContentManager.BuildEditorModel(_services.ContentManager.New<BlogPost>("blogpost"));
blogPost.Item.Blog = blog;
var model = new CreateBlogPostViewModel {
BlogPost = blogPost
};
return View(model);
}
[HttpPost]
public ActionResult Create(string blogSlug, CreateBlogPostViewModel model) {
if (!_services.Authorizer.Authorize(Permissions.CreatePost, T("Couldn't create blog post")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
Blog blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
bool publishNow = false;
if (string.Equals(Request.Form["Command"], "PublishNow")) {
publishNow = true;
}
BlogPost blogPost = _services.ContentManager.Create<BlogPost>("blogpost", publishNow ? VersionOptions.Published : VersionOptions.Draft, bp => { bp.Blog = blog; });
model.BlogPost = _services.ContentManager.UpdateEditorModel(blogPost, this);
if (!ModelState.IsValid) {
_services.TransactionManager.Cancel();
return View(model);
}
//TEMP: (erikpo) ensure information has committed for this record
var session = _sessionLocator.For(typeof(ContentItemRecord));
session.Flush();
return Redirect(Url.BlogPost(blogSlug, model.BlogPost.Item.Slug));
}
public ActionResult Edit(string blogSlug, string postSlug) {
if (!_services.Authorizer.Authorize(Permissions.ModifyPost, T("Couldn't edit blog post")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
Blog blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
BlogPost post = _blogPostService.Get(blog, postSlug, VersionOptions.Latest);
if (post == null)
return new NotFoundResult();
var model = new BlogPostEditViewModel {
BlogPost = _services.ContentManager.BuildEditorModel(post)
};
return View(model);
}
[HttpPost, ActionName("Edit")]
public ActionResult EditPOST(string blogSlug, string postSlug) {
if (!_services.Authorizer.Authorize(Permissions.ModifyPost, T("Couldn't edit blog post")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
Blog blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
BlogPost post = _blogPostService.Get(blog, postSlug, VersionOptions.Latest);
if (post == null)
return new NotFoundResult();
bool publishNow = false;
if (string.Equals(Request.Form["Command"], "PublishNow")) {
publishNow = true;
}
if (publishNow)
_blogPostService.Publish(post);
else
_blogPostService.Unpublish(post);
var model = new BlogPostEditViewModel {
BlogPost = _services.ContentManager.UpdateEditorModel(post, this)
};
TryUpdateModel(model);
if (!ModelState.IsValid) {
_services.TransactionManager.Cancel();
return View(model);
}
_services.Notifier.Information(T("Blog post information updated."));
return Redirect(Url.BlogPostEdit(blog.Slug, post.Slug));
}
[HttpPost]
public ActionResult Delete(string blogSlug, string postSlug) {
if (!_services.Authorizer.Authorize(Permissions.DeletePost, T("Couldn't delete blog post")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
Blog blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
BlogPost post = _blogPostService.Get(blog, postSlug);
if (post == null)
return new NotFoundResult();
_blogPostService.Delete(post);
_services.Notifier.Information(T("Blog post was successfully deleted"));
return Redirect(Url.BlogForAdmin(blogSlug));
}
bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
return TryUpdateModel(model, prefix, includeProperties, excludeProperties);
}
void IUpdateModel.AddModelError(string key, LocalizedString errorMessage) {
ModelState.AddModelError(key, errorMessage.ToString());
}
}
}

View File

@@ -1,32 +1,22 @@
using System.Linq;
using System.Text.RegularExpressions;
using System.Web.Mvc;
using Orchard.Blogs.Extensions;
using Orchard.Blogs.Models;
using Orchard.Blogs.Services;
using Orchard.Blogs.ViewModels;
using Orchard.ContentManagement.Records;
using Orchard.Data;
using Orchard.Localization;
using Orchard.ContentManagement;
using Orchard.Mvc.Results;
using Orchard.UI.Notify;
namespace Orchard.Blogs.Controllers {
[ValidateInput(false)]
public class BlogPostController : Controller, IUpdateModel {
public class BlogPostController : Controller {
private readonly IOrchardServices _services;
private readonly ISessionLocator _sessionLocator;
private readonly IBlogService _blogService;
private readonly IBlogPostService _blogPostService;
public BlogPostController(
IOrchardServices services,
ISessionLocator sessionLocator,
IBlogService blogService,
IBlogPostService blogPostService) {
public BlogPostController(IOrchardServices services, IBlogService blogService, IBlogPostService blogPostService) {
_services = services;
_sessionLocator = sessionLocator;
_blogService = blogService;
_blogPostService = blogPostService;
T = NullLocalizer.Instance;
@@ -77,6 +67,7 @@ namespace Orchard.Blogs.Controllers {
return View(model);
}
//TODO: (erikpo) This should move to be part of the RoutableAspect
public ActionResult Slugify(string value) {
string slug = value;
@@ -99,153 +90,5 @@ namespace Orchard.Blogs.Controllers {
return Json(slug);
}
public ActionResult Create(string blogSlug) {
//TODO: (erikpo) Might think about moving this to an ActionFilter/Attribute
if (!_services.Authorizer.Authorize(Permissions.CreatePost, T("Not allowed to create blog post")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
Blog blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
var blogPost = _services.ContentManager.BuildEditorModel(_services.ContentManager.New<BlogPost>("blogpost"));
blogPost.Item.Blog = blog;
var model = new CreateBlogPostViewModel {
BlogPost = blogPost
};
return View(model);
}
[HttpPost]
public ActionResult Create(string blogSlug, CreateBlogPostViewModel model) {
if (!_services.Authorizer.Authorize(Permissions.CreatePost, T("Couldn't create blog post")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
Blog blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
bool publishNow = false;
if (string.Equals(Request.Form["Command"], "PublishNow")) {
publishNow = true;
}
BlogPost blogPost = _services.ContentManager.Create<BlogPost>("blogpost", publishNow ? VersionOptions.Published : VersionOptions.Draft, bp => { bp.Blog = blog; });
model.BlogPost = _services.ContentManager.UpdateEditorModel(blogPost, this);
if (!ModelState.IsValid) {
_services.TransactionManager.Cancel();
return View(model);
}
//TEMP: (erikpo) ensure information has committed for this record
var session = _sessionLocator.For(typeof(ContentItemRecord));
session.Flush();
return Redirect(Url.BlogPost(blogSlug, model.BlogPost.Item.Slug));
}
public ActionResult Edit(string blogSlug, string postSlug) {
if (!_services.Authorizer.Authorize(Permissions.ModifyPost, T("Couldn't edit blog post")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
Blog blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
BlogPost post = _blogPostService.Get(blog, postSlug, VersionOptions.Latest);
if (post == null)
return new NotFoundResult();
var model = new BlogPostEditViewModel {
BlogPost = _services.ContentManager.BuildEditorModel(post)
};
return View(model);
}
[HttpPost, ActionName("Edit")]
public ActionResult EditPOST(string blogSlug, string postSlug) {
if (!_services.Authorizer.Authorize(Permissions.ModifyPost, T("Couldn't edit blog post")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
Blog blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
BlogPost post = _blogPostService.Get(blog, postSlug, VersionOptions.Latest);
if (post == null)
return new NotFoundResult();
bool publishNow = false;
if (string.Equals(Request.Form["Command"], "PublishNow")) {
publishNow = true;
}
if (publishNow)
_blogPostService.Publish(post);
else
_blogPostService.Unpublish(post);
var model = new BlogPostEditViewModel {
BlogPost = _services.ContentManager.UpdateEditorModel(post, this)
};
TryUpdateModel(model);
if (!ModelState.IsValid) {
_services.TransactionManager.Cancel();
return View(model);
}
_services.Notifier.Information(T("Blog post information updated."));
return Redirect(Url.BlogPostEdit(blog.Slug, post.Slug));
}
[HttpPost]
public ActionResult Delete(string blogSlug, string postSlug) {
if (!_services.Authorizer.Authorize(Permissions.DeletePost, T("Couldn't delete blog post")))
return new HttpUnauthorizedResult();
//TODO: (erikpo) Move looking up the current blog up into a modelbinder
Blog blog = _blogService.Get(blogSlug);
if (blog == null)
return new NotFoundResult();
BlogPost post = _blogPostService.Get(blog, postSlug);
if (post == null)
return new NotFoundResult();
_blogPostService.Delete(post);
_services.Notifier.Information(T("Blog post was successfully deleted"));
return Redirect(Url.BlogForAdmin(blogSlug));
}
bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
return TryUpdateModel(model, prefix, includeProperties, excludeProperties);
}
void IUpdateModel.AddModelError(string key, LocalizedString errorMessage) {
ModelState.AddModelError(key, errorMessage.ToString());
}
}
}

View File

@@ -31,15 +31,15 @@ namespace Orchard.Blogs.Extensions {
}
public static string BlogCreate(this UrlHelper urlHelper) {
return urlHelper.Action("Create", "Blog", new {area = "Orchard.Blogs"});
return urlHelper.Action("Create", "BlogAdmin", new {area = "Orchard.Blogs"});
}
public static string BlogEdit(this UrlHelper urlHelper, string blogSlug) {
return urlHelper.Action("Edit", "Blog", new {blogSlug, area = "Orchard.Blogs"});
return urlHelper.Action("Edit", "BlogAdmin", new {blogSlug, area = "Orchard.Blogs"});
}
public static string BlogDelete(this UrlHelper urlHelper, string blogSlug) {
return urlHelper.Action("Delete", "Blog", new {blogSlug, area = "Orchard.Blogs"});
return urlHelper.Action("Delete", "BlogAdmin", new {blogSlug, area = "Orchard.Blogs"});
}
public static string BlogPost(this UrlHelper urlHelper, string blogSlug, string postSlug) {
@@ -47,15 +47,15 @@ namespace Orchard.Blogs.Extensions {
}
public static string BlogPostCreate(this UrlHelper urlHelper, string blogSlug) {
return urlHelper.Action("Create", "BlogPost", new {blogSlug, area = "Orchard.Blogs"});
return urlHelper.Action("Create", "BlogPostAdmin", new {blogSlug, area = "Orchard.Blogs"});
}
public static string BlogPostEdit(this UrlHelper urlHelper, string blogSlug, string postSlug) {
return urlHelper.Action("Edit", "BlogPost", new {blogSlug, postSlug, area = "Orchard.Blogs"});
return urlHelper.Action("Edit", "BlogPostAdmin", new {blogSlug, postSlug, area = "Orchard.Blogs"});
}
public static string BlogPostDelete(this UrlHelper urlHelper, string blogSlug, string postSlug) {
return urlHelper.Action("Delete", "BlogPost", new {blogSlug, postSlug, area = "Orchard.Blogs"});
return urlHelper.Action("Delete", "BlogPostAdmin", new {blogSlug, postSlug, area = "Orchard.Blogs"});
}
}
}

View File

@@ -76,6 +76,7 @@
<Compile Include="AdminMenu.cs" />
<Compile Include="Controllers\BlogAdminController.cs" />
<Compile Include="Controllers\BlogDriver.cs" />
<Compile Include="Controllers\BlogPostAdminController.cs" />
<Compile Include="Controllers\BlogPostController.cs" />
<Compile Include="Controllers\BlogPostDriver.cs" />
<Compile Include="Extensions\HtmlHelperExtensions.cs" />
@@ -110,8 +111,8 @@
</ItemGroup>
<ItemGroup>
<Content Include="Package.txt" />
<Content Include="Views\BlogPost\Create.ascx" />
<Content Include="Views\BlogPost\Edit.ascx" />
<Content Include="Views\BlogPostAdmin\Create.ascx" />
<Content Include="Views\BlogPostAdmin\Edit.ascx" />
<Content Include="Views\BlogPost\ListByArchive.ascx" />
<Content Include="Views\DisplayTemplates\Items\Blogs.Blog.DetailAdmin.ascx" />
<Content Include="Views\BlogAdmin\Item.ascx" />
@@ -125,8 +126,8 @@
<Content Include="Views\DisplayTemplates\Items\Blogs.Blog.Summary.ascx" />
<Content Include="Views\EditorTemplates\Parts\Blogs.BlogPost.Publish.ascx" />
<Content Include="Views\BlogPost\Item.ascx" />
<Content Include="Views\Blog\Create.ascx" />
<Content Include="Views\Blog\Edit.ascx" />
<Content Include="Views\BlogAdmin\Create.ascx" />
<Content Include="Views\BlogAdmin\Edit.ascx" />
<Content Include="Views\Blog\Item.ascx" />
<Content Include="Views\DisplayTemplates\Items\Blogs.BlogPost.SummaryAdmin.ascx" />
<Content Include="Views\EditorTemplates\Parts\Blogs.Blog.Fields.ascx" />

View File

@@ -40,7 +40,7 @@ namespace Orchard.Blogs {
"Admin/Blogs/Create",
new RouteValueDictionary {
{"area", "Orchard.Blogs"},
{"controller", "Blog"},
{"controller", "BlogAdmin"},
{"action", "Create"}
},
new RouteValueDictionary(),
@@ -54,7 +54,7 @@ namespace Orchard.Blogs {
"Admin/Blogs/{blogSlug}/Edit",
new RouteValueDictionary {
{"area", "Orchard.Blogs"},
{"controller", "Blog"},
{"controller", "BlogAdmin"},
{"action", "Edit"}
},
new RouteValueDictionary {
@@ -70,7 +70,7 @@ namespace Orchard.Blogs {
"Admin/Blogs/{blogSlug}/Delete",
new RouteValueDictionary {
{"area", "Orchard.Blogs"},
{"controller", "Blog"},
{"controller", "BlogAdmin"},
{"action", "Delete"}
},
new RouteValueDictionary {
@@ -102,7 +102,7 @@ namespace Orchard.Blogs {
"Admin/Blogs/{blogSlug}/Posts/Create",
new RouteValueDictionary {
{"area", "Orchard.Blogs"},
{"controller", "BlogPost"},
{"controller", "BlogPostAdmin"},
{"action", "Create"}
},
new RouteValueDictionary {
@@ -118,7 +118,7 @@ namespace Orchard.Blogs {
"Admin/Blogs/{blogSlug}/Posts/{postSlug}/Edit",
new RouteValueDictionary {
{"area", "Orchard.Blogs"},
{"controller", "BlogPost"},
{"controller", "BlogPostAdmin"},
{"action", "Edit"}
},
new RouteValueDictionary {
@@ -134,7 +134,7 @@ namespace Orchard.Blogs {
"Admin/Blogs/{blogSlug}/Posts/{postSlug}/Delete",
new RouteValueDictionary {
{"area", "Orchard.Blogs"},
{"controller", "BlogPost"},
{"controller", "BlogPostAdmin"},
{"action", "Delete"}
},
new RouteValueDictionary {
@@ -145,22 +145,6 @@ namespace Orchard.Blogs {
},
new MvcRouteHandler())
},
//new RouteDescriptor {
// Route = new Route(
// "Admin/Blogs/{blogSlug}/Posts",
// new RouteValueDictionary {
// {"area", "Orchard.Blogs"},
// {"controller", "BlogPostAdmin"},
// {"action", "List"}
// },
// new RouteValueDictionary {
// {"blogSlug", new IsBlogConstraint(_blogService)}
// },
// new RouteValueDictionary {
// {"area", "Orchard.Blogs"}
// },
// new MvcRouteHandler())
// },
new RouteDescriptor {
Route = new Route(
"Admin/Blogs",

View File

@@ -2,17 +2,14 @@ using System.Collections.Generic;
using System.Linq;
using Orchard.Blogs.Models;
using Orchard.Core.Common.Records;
using Orchard.Data;
using Orchard.ContentManagement;
namespace Orchard.Blogs.Services {
public class BlogService : IBlogService {
private readonly IContentManager _contentManager;
private readonly IRepository<BlogRecord> _blogRepository;
public BlogService(IContentManager contentManager, IRepository<BlogRecord> blogRepository) {
public BlogService(IContentManager contentManager) {
_contentManager = contentManager;
_blogRepository = blogRepository;
}
public Blog Get(string slug) {
@@ -29,7 +26,7 @@ namespace Orchard.Blogs.Services {
}
public void Delete(Blog blog) {
_blogRepository.Delete(blog.Record);
_contentManager.Remove(blog.ContentItem);
}
}
}