mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-24 13:33:34 +08:00
Wrapped up the model for blog views into some view models and dumped out posts on a blog.
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4041908
This commit is contained in:
@@ -1,18 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Blogs.Models;
|
||||
using Orchard.Blogs.Services;
|
||||
using Orchard.Blogs.ViewModels;
|
||||
using Orchard.Mvc.Results;
|
||||
|
||||
namespace Orchard.Blogs.Controllers {
|
||||
public class BlogController : Controller {
|
||||
private readonly IBlogService _blogService;
|
||||
private readonly IBlogPostService _blogPostService;
|
||||
|
||||
public BlogController(IBlogService blogService) {
|
||||
public BlogController(IBlogService blogService, IBlogPostService blogPostService) {
|
||||
_blogService = blogService;
|
||||
_blogPostService = blogPostService;
|
||||
}
|
||||
|
||||
public ActionResult List() {
|
||||
return View(_blogService.Get());
|
||||
return View(new BlogsViewModel {Blogs = _blogService.Get()});
|
||||
}
|
||||
|
||||
//TODO: (erikpo) Should think about moving the slug parameter and get call and null check up into a model binder or action filter
|
||||
@@ -22,7 +26,9 @@ namespace Orchard.Blogs.Controllers {
|
||||
if (blog == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
return View(blog);
|
||||
IEnumerable<BlogPost> posts = _blogPostService.Get(blog);
|
||||
|
||||
return View(new BlogViewModel {Blog = blog, Posts = posts});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user