Home>

I. General description

1. Realize the function

Class diagram

Since most of the classes are implemented in the article,There is only one consultation class here.

Second, create a consulting model class

Add the class consultation (consultation model) to the ninesky.models project. This model is similar to article and is an extension of commonmodel.

1. Add the consultation class.

using system;
using system.componentmodel.dataannotations;
namespace ninesky.models
{
  ///<summary>
  ///consulting model
  ///<remarks>created: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 number
    ///</summary>
    [display (name="qqnumber")]
    [stringlength (16, minimumlength=6, errormessage="{1}-{0} numbers")]
    public string qq {get;set;}
    ///<summary>
    ///email address
    ///</summary>
    [display (name="email address")]
    [datatype (datatype.emailaddress, errormessage="You 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>
    ///Is it public
    ///</summary>
    [display (name="Is it public")]
    public bool ispublic {get;set;}
    ///<summary>
    ///Reply content
    ///</summary>
    [display (name="Response")]
    public string replycontent {get;set;}
    ///<summary>
    ///Response Time
    ///</summary>
    [display (name="Response time")]
    public nullable<datetime>replytime {get;set;}
  }
}

2.Add foreign keys to commonmodel

Third, add a controllerOpen the ninesky.web project and add a 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>
  ///Consulting controller
  ///</summary>
  [authorize]
  public class consultationcontroller:controller
  {
    private interfacecommonmodelservice commonmodelservice;
    public consultationcontroller () {commonmodelservice=new commonmodelservice ();}
  }
}

The model is a foreign key to the commonmodel, and the commonmodel can be directly operated during operation.No need to add dal, bll, the content is relatively simple.

  • Previous ASPNET MVC5 Website Development My Consultation List and Add Consultation (12)
  • Next Solution to insufficient website permissions after IIS75 configuration in Win2008 R2