ASP.NET MVC5 website development practice Member region article management framework

I. General description

First, let's look at the functions to be realized in the article management plan:

Take a look at the class diagram again

Here Category is column; CommonModel is public model; Article is Article; Attachment is Attachment;

CommonModel is the extracted public part of content management. For example, articles, consulting and even products have some common content, which is extracted as a class. CommonModel may contain an article, a set of attachments, and a series of comments, which are already represented in the relationship class diagram between them.

 

II. Structure

This order is the same as before

1,IDAL

Adding interface InterfaceCommonModelRepository in IDAL only inherits from InterfaceBaseRepository, without adding any other content.

 

namespace Ninesky.IDAL
{
    /// <summary>
    ///Common model interface
    /// <remarks>
    ///Created on February 23, 2014
    ///Revised: February 28, 2014
    /// </remarks>
    /// </summary>
    public interface InterfaceCommonModelRepository:InterfaceBaseRepository<Models.CommonModel> {

    }
}

 

Then add interface category, interface article and interface attachment in the same way as the common model interface.

2,DAL

Whether to implement the IDAL interface in DAL or start with CommonModel, first add CommonModelRepository, which is the same as the original direct inheritance without any code.

 

namespace Ninesky.DAL
{
    /// <summary>
    ///Public model warehouse
    /// <remarks>
    ///Created on February 23, 2014
    /// </remarks>
    /// </summary>
    public class CommonModelRepository:BaseRepository<Models.CommonModel>, IDAL.InterfaceCommonModel
    {
    }
}

 

Then add category repository, article repository, attachment repository.

3.IBLL

This time, we will start with InterfaceCategoryService, interfacerticleservice, interfacecomponentservice, interfaceattachmentservice. The content of InterfaceCommonModelService is put at the end.

InterfaceCategoryService

The specific functions will be written when the column is made, and the time and space are temporarily here.

 

namespace Ninesky.IBLL
{
    /// <summary>
    ///Column service interface
    /// <remarks>
    ///Created on February 23, 2014
    /// </remarks>
    /// </summary>
    public class InterfaceCategoryService:InterfaceBaseService<Models.Category>
    {
    }
}

 

4.BLL

Similarly, start with CategoryService, and then add ArticleService and 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>
    ///Created on February 27, 2014
    /// </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 controllercategorycontroller

 

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

 

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

 

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 on March 5, 2014
    /// </remarks>
    /// </summary>
    [Authorize]
    public class AttachmentController : Controller
    {
 }
}

 

Posted by glcarlstrom on Tue, 03 Dec 2019 09:28:44 -0800