Home>

I. General description

First look at the functions that the article management device wants to achieve:

Look at the class diagram again

Here category is the column;commonmodel is the public model;article is an article;attachment is an attachment;

commonmodel is the extracted common part of content management,Like articles, consulting, and even products have some common content. Here it is extracted separately as a class.commonmodel may contain an article,Contains a set of attachments,Contains a series of comments,The relationship between them has been shown in the class diagram.

Second, build the architecture

This sequence is the same as before

1.idal

Adding interface interfacecommonmodelrepository to idal is actually just inherited from interfacebaserepository, without adding anything else.

namespace ninesky.idal
{
 ///<summary>
 ///public model interface
 ///<remarks>
 ///Created:2014.02.23
 ///Modification:2014.02.28
 ///</remarks>
 ///</summary>
 public interface interfacecommonmodelrepository:interfacebaserepository<models.commonmodel>{
 }
}

Then add interfacecategory, interfacearticle, interfaceattachment one by one in the same way as the public model interface.

2.daldal is the implementation of the idal interface,Or start from commonmodel, add commonmodelrepository first, and inherit directly without the same code as the original.

namespace ninesky.dal
{
 ///<summary>
 ///Public model storage
 ///<remarks>
 ///Created:2014.02.23
 ///</remarks>
 ///</summary>
 public class commonmodelrepository:baserepository<models.commonmodel>, idal.interfacecommonmodel
 {
 }
}

Then add categoryrepository, articlerepository, and attachmentrepository in order.

3.ibll

This time, start with interfacecategoryservice, interfacearticleservice, interfacecommentservice, interfaceattachmentservice. interfacecommonmodelservice puts more content at the end.

interfacecategoryservice

Specific functions will be written when doing the column,It's empty for now.

namespace ninesky.ibll
{
 ///<summary>
 ///Column service interface
 ///<remarks>
 ///Created:2014.02.23
 ///</remarks>
 ///</summary>
 public class interfacecategoryservice:interfacebaseservice<models.category>
 {
 }
}

4.bll

Also start with categoryservice, then add articleservice and attachmentservice in this order. commonmodelservice.

using ninesky.dal;
using ninesky.ibll;
using ninesky.models;
using system;
using system.collections.generic;
using system.linq;
namespace ninesky.bll
{
 ///<summary>
 ///column services
 ///<remarks>
 ///Created:2014.02.27
 ///</remarks>
 ///</summary>
 public class categoryservice:baseservice<category> ;, interfacecategoryservice
 {
 public categoryservice ():base (repositoryfactory.categoryrepository) {}
 }
}

5.web

Add three empty controllers under the member area of ​​the web project.

Categorycontroller

using system;
using system.collections.generic;
using system.linq;
using system.web;
using system.web.mvc;
using ninesky.ibll;
using ninesky.bll;
using ninesky.models;
namespace ninesky.web.areas.member.controllers
{
 [authorize]
 public class categorycontroller:controller
 {
 private interfacecategoryservice categoryrepository;
 public categorycontroller () {categoryrepository=new categoryservice ();}
 }
}

Articlecontroller

using system;
using system.collections.generic;
using system.linq;
using system.web;
using system.web.mvc;
using ninesky.models;
using ninesky.ibll;
using ninesky.bll;
namespace ninesky.web.areas.member.controllers
{
 public class articlecontroller:controller
 {
 private interfacearticleservice articleservice;
 private interfacecommonmodelservice commonmodelservice;
 public articlecontroller () {articleservice=new articleservice ();commonmodelservice=new commonmodelservice ();}
 }
}

Attachmentcontroller

using system;
using system.collections.generic;
using system.linq;
using system.collections;
using system.web;
using system.web.mvc;
using system.io;
using ninesky.ibll;
using ninesky.bll;
using ninesky.models;
namespace ninesky.web.areas.member.controllers
{
 ///<summary>
 ///accessory controller
 ///<remarks>
 ///Created:2014.03.05
 ///</remarks>
 ///</summary>
 [authorize]
 public class attachmentcontroller:controller
 {
 }
}
  • Previous Anatomy of C ++ 's Object-Oriented Programming
  • Next Detailed explanation of ssh installation and scp command under linux