Architecture of ASP. NET MVC5 website development consulting management (11), mvc5 website development
I. General description
1. Implement Functions
2. Class Diagram
Because most classes are implemented in this article, only one Consultation class is added here.
Ii. Create a consulting Model
Add the Consultation class (consulting model) to the Ninesky. Models project. This model is similar to the CommonModel extension of Article.
1. Add the Consultation class.
Using System; using System. componentModel. dataAnnotations; namespace Ninesky. models {/// <summary> /// consulting model /// <remarks> Create: 2014.02.06 </remarks> /// </summary> public class Consultation {[Key] public int ConsultationID {get; set ;} /// <summary> /// Name /// </summary> [Display (Name = "Name")] [Required (ErrorMessage = "Required")] public string Name {get; set ;}/// <summary> /// QQ No. /// </summary> [Display (Name = "QQ number")] [StringLength (16, MinimumLength = 6, ErrorMessage = "{1}-{0} digits")] public string QQ {get; set ;} /// <summary> /// Email address /// </summary> [Display (Name = "Email address")] [DataType (DataType. emailAddress, ErrorMessage = "the correct Email address must be entered")] public string Email {get; set ;} /// <summary> /// content /// </summary> [Display (Name = "content")] [Required (ErrorMessage = "Required")] [StringLength (1000, ErrorMessage = "must be less than {0} characters")] public string Content {get; set ;} /// <summary> /// whether to make public /// </summary> [Display (Name = "public")] public bool IsPublic {get; set ;} /// <summary> /// reply content /// </summary> [Display (Name = "Reply content")] public string ReplyContent {get; set ;} /// <summary> /// response time /// </summary> [Display (Name = "reply time")] public Nullable <DateTime> ReplyTime {get; set ;}}}
2. Add a foreign key to CommonModel
3. Add a controller
Open the Ninesky. Web project and add the Consultation controller in the Member area.
Using Ninesky. BLL; using Ninesky. IBLL; using Ninesky. models; using System. linq; using System. web. mvc; namespace Ninesky. web. areas. member. controllers {// <summary> // query Controller /// </summary> [Authorize] public class ConsultationController: Controller {private InterfaceCommonModelService commonModelService; public ConsultationController () {commonModelService = new CommonModelService ();}}}
The model is the foreign key of the CommonModel. During the operation, you can directly perform the CommonModel operation without adding DAL and BLL. The content is relatively simple.
A series of articles on ASP. NET MVC5 website development are coming to an end soon. I hope these articles can help you better Develop ASP. NET MVC5 website.