2009-11-24 00:26:24 +08:00
|
|
|
using System.Collections.Generic;
|
2009-11-21 07:31:49 +08:00
|
|
|
using System.Web.Mvc;
|
|
|
|
using Orchard.Blogs.Models;
|
|
|
|
using Orchard.Blogs.Services;
|
2009-11-24 00:26:24 +08:00
|
|
|
using Orchard.Blogs.ViewModels;
|
2009-11-21 07:31:49 +08:00
|
|
|
using Orchard.Mvc.Results;
|
|
|
|
|
|
|
|
namespace Orchard.Blogs.Controllers {
|
|
|
|
public class BlogController : Controller {
|
|
|
|
private readonly IBlogService _blogService;
|
2009-11-24 00:26:24 +08:00
|
|
|
private readonly IBlogPostService _blogPostService;
|
2009-11-21 07:31:49 +08:00
|
|
|
|
2009-11-24 00:26:24 +08:00
|
|
|
public BlogController(IBlogService blogService, IBlogPostService blogPostService) {
|
2009-11-21 07:31:49 +08:00
|
|
|
_blogService = blogService;
|
2009-11-24 00:26:24 +08:00
|
|
|
_blogPostService = blogPostService;
|
2009-11-21 07:31:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public ActionResult List() {
|
2009-11-24 00:26:24 +08:00
|
|
|
return View(new BlogsViewModel {Blogs = _blogService.Get()});
|
2009-11-21 07:31:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//TODO: (erikpo) Should think about moving the slug parameter and get call and null check up into a model binder or action filter
|
2009-11-21 08:38:41 +08:00
|
|
|
public ActionResult Item(string blogSlug) {
|
|
|
|
Blog blog = _blogService.Get(blogSlug);
|
2009-11-21 07:31:49 +08:00
|
|
|
|
|
|
|
if (blog == null)
|
|
|
|
return new NotFoundResult();
|
|
|
|
|
2009-11-24 00:26:24 +08:00
|
|
|
IEnumerable<BlogPost> posts = _blogPostService.Get(blog);
|
|
|
|
|
|
|
|
return View(new BlogViewModel {Blog = blog, Posts = posts});
|
2009-11-21 07:31:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|