Starting to give more attention to generic content management

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-07-08 10:12:34 -07:00
parent 3c0dc81d7d
commit f7803da193
8 changed files with 82 additions and 61 deletions

View File

@@ -48,10 +48,17 @@ namespace Orchard.Core.Contents.Controllers {
const int pageSize = 20;
var skip = (Math.Max(model.Page ?? 0, 1) - 1) * pageSize;
var query = _contentManager.Query(VersionOptions.Latest);
var query = _contentManager.Query(VersionOptions.Latest, _contentDefinitionManager.ListTypeDefinitions().Select(ctd => ctd.Name).ToArray());
if (!string.IsNullOrEmpty(model.Id)) {
query = query.ForType(model.Id);
if (!string.IsNullOrEmpty(model.TypeName)) {
var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(model.TypeName);
if (contentTypeDefinition == null)
return new NotFoundResult();
model.TypeDisplayName = !string.IsNullOrWhiteSpace(contentTypeDefinition.DisplayName)
? contentTypeDefinition.DisplayName
: contentTypeDefinition.Name;
query = query.ForType(model.TypeName);
}
var contentItems = query.Slice(skip, pageSize);
@@ -148,6 +155,18 @@ namespace Orchard.Core.Contents.Controllers {
return RedirectToAction("Edit", new RouteValueDictionary { { "Id", contentItem.Id } });
}
[HttpPost, ActionName("Remove")]
public ActionResult RemovePOST(int id, string returnUrl) {
var contentItem = _contentManager.Get(id);
if (contentItem != null)
_contentManager.Remove(contentItem);
if (!String.IsNullOrEmpty(returnUrl))
return Redirect(returnUrl);
return RedirectToAction("List");
}
private void PrepareEditorViewModel(ContentItemViewModel itemViewModel) {
if (string.IsNullOrEmpty(itemViewModel.TemplateName)) {
itemViewModel.TemplateName = "Items/Contents.Item";