开发者

Creating an entity service with different views/sights depending on user's rights

For a custom blog implementation (written in ASP.NET MVC 3), I wrote a PostService class implementing an IPostService interface that is retrieving Post entities representing blog posts. However, not every post is visible by default; the property IsPublished distinguishes between published blog posts and saved drafts. O开发者_StackOverflow中文版n the blog's landing page, I would like to display a list of the five latest posts. Of course, only published posts are supposed to appear there.

There are several different places in code where an implementation of IPostService is injected into the corresponding constructor by Ninject 2, e.g. for a class listing the monthly post archives etc. In my administration area, the service is supposed to return all blog posts including drafts. On the blog itself, the service is always supposed to only deal with published posts.

Where do I configure whether to include unpublished posts in the RetrieveAll method of IPostService? To me, that sounds like a dependency container injection issue.


Why don't you add two methods to your service RetrieveAll, RetrievePublished and let the controller decide what it wants to display?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜