I. GENERAL description
1, realize the function
2. Class Diagram
Since most of the classes are implemented in the article, there is only one more consultation class.
Ii. Creating consulting model classes
Add the class consultation (consulting model) to the Ninesky.models project, which is a commonmodel extension similar to article.
1, add 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")] P
Ublic string Name {get; set;} <summary>///QQ number///</summary> [Display (Name = "QQ number")] [Stringlength (16,minimumlength=6
, errormessage = "{1}-{0} number")] public string QQ {get; set;} <summary>///Email address///</summary> [Display (Name = "email address")] [DataType (Datatype.emaila
Ddress,errormessage= "must enter the correct email address")] 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 expose///</summary> [Display (Name = "whether public")]] publicly bool IsPublic {get; set ; ///<summary>///reply content///</summary> [Display (Name = "Reply Content")] public string Replyconte
NT {get; set;} <summary>///reply Time///</summary> [Display (Name = "Reply Time")] public nullable<datetime>
replytime {get; set;} }
}
2, add the foreign key in the Commonmodel
Third, add controller
Open Ninesky.web Project Add consultation controller to 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>
///Advisory Controller
///</summary >
[Authorize] public
class Consultationcontroller:controller
{
private Interfacecommonmodelservice Commonmodelservice;
Public Consultationcontroller () {commonmodelservice = new Commonmodelservice ();}}}
The model is Commonmodel foreign key, the operation directly to the Commonmodel operation on the line, do not need to add dal,bll, the content is relatively simple.
About ASP.net MVC5 website development A series of articles finishing is nearing the end, hope these articles can help everybody to develop the ASP.net MVC5 website better.