ASP. NET MVC5 website development Article Management Architecture (7), mvc5 website development

Source: Internet
Author: User

ASP. NET MVC5 website development Article Management Architecture (7), mvc5 website development

I. General description
Let's take a look at the functions of the article's management ideas:

Let's look at the class diagram.

Here, Category is a topic; CommonModel is a public model; Article is an Article; Attachment is an Attachment;

CommonModel is a public part extracted from the content management module, such as articles, consulting, and even products. Here, it is extracted separately as a class. CommonModel may contain an article, a group of attachments, and a series of comments. The relationship between them is shown in the graph.

Ii. Build Architecture
This sequence is the same as before.

1. IDAL
The interface InterfaceCommonModelRepository added to IDAL is inherited from InterfaceBaseRepository without adding any other content.

Namespace Ninesky. IDAL {/// <summary> /// public model interface /// <remarks> /// create: 2014.02.23 // modify: 2014.02.28 // </remarks> /// </summary> public interface InterfaceCommonModelRepository: InterfaceBaseRepository <Models. commonModel> {}}

Add InterfaceCategory, InterfaceArticle, and InterfaceAttachment in sequence, in the same way as the public model interface.

2. DAL
Whether to implement the IDAL interface in DAL or add CommonModelRepository first from CommonModel. It is also similar to the original direct inheritance without any code.

Namespace Ninesky. DAL {// <summary> /// public model warehouse /// <remarks> /// create: 2014.02.23 // </remarks> /// </summary> public class CommonModelRepository: BaseRepository <Models. commonModel>, IDAL. interfaceCommonModel {}}

Add CategoryRepository, ArticleRepository, and AttachmentRepository in sequence.

3. IBLL

This time, we will start with InterfaceCategoryService, InterfaceArticleService, InterfaceCommentService, and InterfaceAttachmentService. InterfaceCommonModelService is mostly placed at the end.
InterfaceCategoryService

The specific functions will be written when you are working on the topic.

Namespace Ninesky. IBLL {/// <summary> /// topic service interface /// <remarks> /// create: 2014.02.23 // </remarks> /// </summary> public class InterfaceCategoryService: InterfaceBaseService <Models. category> {}}

4. BLL

Similarly, you must first start with CategoryService, and then add ArticleService and AttachmentService in sequence. CommonModelService.

Using Ninesky. DAL; using Ninesky. IBLL; using Ninesky. models; using System. collections. generic; using System. linq; namespace Ninesky. BLL {/// <summary> /// topic service /// <remarks> /// create: 2014.02.27 // </remarks> /// </summary> public class CategoryService: BaseService <Category>, InterfaceCategoryService {public CategoryService (): base (RepositoryFactory. categoryRepository ){}}}

5. Web

Add three empty controllers in the Member area of the web Project.

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

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 architecture is over. The following describes how to implement the functions of this article!

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.