asp.net MVC5 website Development article management structure (vii) _ Practical skills

Source: Internet
Author: User

I. GENERAL description
Let's take a look at what the article manages to accomplish:

Look at the class diagram again

Here category is a column; Commonmodel is a public model; article is an article; attachment is an accessory;

Commonmodel is a public part of content management, such as articles, consulting, and even products that have some common content that is extracted here separately as a class. Commonmodel may contain an article, including a set of attachments, that contains a series of comments that have been shown in the relationship class diagram.

Second, build the structure
This is the same order root as before.

1, Idal
Add interface interfacecommonmodelrepository to Idal, actually just inherit from Interfacebaserepository, without adding any other content.

Namespace Ninesky.idal
{
 ///<summary>
 ///Common Model interface
 ///<remarks>
 ///creation: 2014.02.23
 ///Modification: 2014.02.28
 ///</remarks>
 ///</summary> Public
 interface interfacecommonmodelrepository:interfacebaserepository<models.commonmodel> {

 }
}

Add the interfacecategory,interfacearticle,interfaceattachment in turn, in the same way as the common model interface.

2, DAL
Dal is the implementation of the Idal interface, or starting from Commonmodel, first add commonmodelrepository, is also the same as the original directly inherited no code.

Namespace Ninesky.dal
{
 ///<summary>
 ///public model warehousing
 ///<remarks>
 ///creation: 2014.02.23
 ///</remarks>
 ///</summary> public
 class commonmodelrepository:baserepository< Models.commonmodel>, Idal. Interfacecommonmodel
 {
 }
}

Then add the categoryrepository,articlerepository,attachmentrepository in turn.

3.IBLL

Let's start with Interfacecategoryservice, Interfacearticleservice,interfacecommentservice,interfaceattachmentservice. Interfacecommonmodelservice content is more in the end.
Interfacecategoryservice

Specific features will be done in the time to write the column, here temporarily empty.

Namespace Ninesky.ibll
{
 ///<summary>
 ///Column Service interface
 ///<remarks>
 ///creation: 2014.02.23
 ///</remarks>
 ///</summary> public
 class Interfacecategoryservice:interfacebaseservice <Models.Category>
 {
 }
}

4.BLL

Also start with Categoryservice, and then add the Articleservice,attachmentservice in turn. Commonmodelservice.

Using Ninesky.dal;
Using NINESKY.IBLL;
Using Ninesky.models;
Using System;
Using System.Collections.Generic;
Using System.Linq;

Namespace Ninesky.bll
{
 ///<summary>
 ///column service
 ///<remarks>
 ///creation: 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.

Column Controller 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 ();}}}

Article Controller 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 ();}
 }
}

Attachment Controller 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>
 ///attachment controller
 ///<remarks >
 ///Create: 2014.03.05
 ///</remarks>
 ///</summary>
 [Authorize] public
 class Attachmentcontroller:controller
 {
 }
}

The end of the architecture, the following is the implementation of the article related functions!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.