2009-12-07 23:37:47 +00:00
|
|
|
using System.Linq;
|
2009-11-20 23:31:49 +00:00
|
|
|
using System.Web.Mvc;
|
|
|
|
using Orchard.Blogs.Models;
|
|
|
|
using Orchard.Blogs.Services;
|
2009-11-23 16:26:24 +00:00
|
|
|
using Orchard.Blogs.ViewModels;
|
2009-11-23 19:24:53 +00:00
|
|
|
using Orchard.Data;
|
2009-11-20 23:31:49 +00:00
|
|
|
using Orchard.Mvc.Results;
|
2009-12-03 22:53:49 +00:00
|
|
|
using Orchard.Security;
|
2009-11-23 17:34:46 +00:00
|
|
|
using Orchard.UI.Notify;
|
2009-11-20 23:31:49 +00:00
|
|
|
|
|
|
|
namespace Orchard.Blogs.Controllers {
|
2009-11-25 05:45:50 +00:00
|
|
|
[ValidateInput(false)]
|
2010-01-11 22:07:03 +00:00
|
|
|
public class BlogController : Controller {
|
2010-01-11 21:05:24 +00:00
|
|
|
private readonly IOrchardServices _services;
|
2009-11-20 23:31:49 +00:00
|
|
|
private readonly IBlogService _blogService;
|
|
|
|
|
2010-01-11 21:05:24 +00:00
|
|
|
public BlogController(IOrchardServices services, ISessionLocator sessionLocator, IAuthorizer authorizer, INotifier notifier, IBlogService blogService) {
|
|
|
|
_services = services;
|
2009-11-20 23:31:49 +00:00
|
|
|
_blogService = blogService;
|
|
|
|
}
|
|
|
|
|
2009-12-03 01:37:45 +00:00
|
|
|
public ActionResult List() {
|
2009-12-08 09:21:13 +00:00
|
|
|
var model = new BlogsViewModel {
|
2010-01-11 21:05:24 +00:00
|
|
|
Blogs = _blogService.Get().Select(b => _services.ContentManager.BuildDisplayModel(b, "Summary"))
|
2009-12-08 09:21:13 +00:00
|
|
|
};
|
2009-12-08 06:31:44 +00:00
|
|
|
|
2009-12-08 09:21:13 +00:00
|
|
|
return View(model);
|
2009-11-20 23:31:49 +00:00
|
|
|
}
|
|
|
|
|
2009-11-23 17:34:46 +00:00
|
|
|
//TODO: (erikpo) Should move the slug parameter and get call and null check up into a model binder
|
2009-11-21 00:38:41 +00:00
|
|
|
public ActionResult Item(string blogSlug) {
|
|
|
|
Blog blog = _blogService.Get(blogSlug);
|
2009-11-20 23:31:49 +00:00
|
|
|
|
|
|
|
if (blog == null)
|
|
|
|
return new NotFoundResult();
|
|
|
|
|
2009-12-08 09:21:13 +00:00
|
|
|
var model = new BlogViewModel {
|
2010-01-11 21:05:24 +00:00
|
|
|
Blog = _services.ContentManager.BuildDisplayModel(blog, "Detail")
|
2009-12-08 09:21:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return View(model);
|
2009-11-20 23:31:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|