Changing page delete action to use the id instead of slug

--HG--
extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045805
This commit is contained in:
skewed
2010-01-21 21:59:57 +00:00
parent b045c6d1dd
commit 3a924430d2
3 changed files with 7 additions and 2 deletions

View File

@@ -220,11 +220,11 @@ namespace Orchard.Pages.Controllers {
}
[HttpPost]
public ActionResult Delete(string pageSlug) {
public ActionResult Delete(int id) {
if (!_services.Authorizer.Authorize(Permissions.DeletePages, T("Couldn't delete page")))
return new HttpUnauthorizedResult();
Page page = _pageService.Get(pageSlug);
Page page = _pageService.Get(id);
if (page == null)
return new NotFoundResult();

View File

@@ -7,6 +7,7 @@ namespace Orchard.Pages.Services {
IEnumerable<Page> Get();
IEnumerable<Page> Get(PageStatus status);
Page Get(string slug);
Page Get(int id);
Page GetPageOrDraft(string slug);
Page GetPageOrDraft(int id);
Page GetLatest(string slug);

View File

@@ -38,6 +38,10 @@ namespace Orchard.Pages.Services {
return contentItems.Select(ci => ci.As<Page>());
}
public Page Get(int id) {
return _contentManager.Get<Page>(id);
}
public Page Get(string slug) {
return
_contentManager.Query("page").Join<RoutableRecord>().Where(rr => rr.Slug == slug).List().FirstOrDefault