mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 04:43:35 +08:00

--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045254
44 lines
1.4 KiB
C#
44 lines
1.4 KiB
C#
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using Orchard.Blogs.Models;
|
|
using Orchard.Blogs.Services;
|
|
using Orchard.Blogs.ViewModels;
|
|
using Orchard.Data;
|
|
using Orchard.Mvc.Results;
|
|
using Orchard.Security;
|
|
using Orchard.UI.Notify;
|
|
|
|
namespace Orchard.Blogs.Controllers {
|
|
[ValidateInput(false)]
|
|
public class BlogController : Controller {
|
|
private readonly IOrchardServices _services;
|
|
private readonly IBlogService _blogService;
|
|
|
|
public BlogController(IOrchardServices services, ISessionLocator sessionLocator, IAuthorizer authorizer, INotifier notifier, IBlogService blogService) {
|
|
_services = services;
|
|
_blogService = blogService;
|
|
}
|
|
|
|
public ActionResult List() {
|
|
var model = new BlogsViewModel {
|
|
Blogs = _blogService.Get().Select(b => _services.ContentManager.BuildDisplayModel(b, "Summary"))
|
|
};
|
|
|
|
return View(model);
|
|
}
|
|
|
|
//TODO: (erikpo) Should move the slug parameter and get call and null check up into a model binder
|
|
public ActionResult Item(string blogSlug) {
|
|
Blog blog = _blogService.Get(blogSlug);
|
|
|
|
if (blog == null)
|
|
return new NotFoundResult();
|
|
|
|
var model = new BlogViewModel {
|
|
Blog = _services.ContentManager.BuildDisplayModel(blog, "Detail")
|
|
};
|
|
|
|
return View(model);
|
|
}
|
|
}
|
|
} |