ASP.NET?MVC5網(wǎng)站開發(fā)咨詢管理的架構(十一)
一、總體說明
1、實現(xiàn)功能
2、類圖
由于文章部分把大部分類都是實現(xiàn)了,這里僅多了一個Consultation類。
二、創(chuàng)建咨詢模型類
在Ninesky.Models項目添加類Consultation(咨詢模型),該模型跟Article類似都是CommonModel的擴展。
1、添加Consultation類。
using System; using System.ComponentModel.DataAnnotations; namespace Ninesky.Models { /// <summary> /// 咨詢模型 /// <remarks>創(chuàng)建:2014.02.06</remarks> /// </summary> public class Consultation { [Key] public int ConsultationID { get; set; } /// <summary> /// 姓名 /// </summary> [Display(Name = "姓名")] [Required(ErrorMessage="必填")] public string Name { get; set; } /// <summary> /// QQ號 /// </summary> [Display(Name = "QQ號碼")] [StringLength(16,MinimumLength=6, ErrorMessage = "{1}-{0}個數(shù)字")] public string QQ { get; set; } /// <summary> /// Email地址 /// </summary> [Display(Name = "Email地址")] [DataType(DataType.EmailAddress,ErrorMessage="必須輸入正確的Email地址")] public string Email { get; set; } /// <summary> /// 內(nèi)容 /// </summary> [Display(Name = "內(nèi)容")] [Required(ErrorMessage = "必填")] [StringLength(1000, ErrorMessage = "必須少于{0}個字符")] public string Content { get; set; } /// <summary> /// 是否公開 /// </summary> [Display(Name = "是否公開")] public bool IsPublic { get; set; } /// <summary> /// 回復內(nèi)容 /// </summary> [Display(Name = "回復內(nèi)容")] public string ReplyContent { get; set; } /// <summary> /// 回復時間 /// </summary> [Display(Name = "回復時間")] public Nullable<DateTime> ReplyTime { get; set; } } }
2、在CommonModel里添加外鍵
三、添加控制器
打開Ninesky.Web項目在Member區(qū)域添加Consultation控制器
using Ninesky.BLL; using Ninesky.IBLL; using Ninesky.Models; using System.Linq; using System.Web.Mvc; namespace Ninesky.Web.Areas.Member.Controllers { /// <summary> /// 咨詢控制器 /// </summary> [Authorize] public class ConsultationController : Controller { private InterfaceCommonModelService commonModelService; public ConsultationController() { commonModelService = new CommonModelService(); } } }
模型是CommonModel的外鍵,操作時直接對CommonModel操作就行,不需要再添加DAL,BLL,內(nèi)容比較簡單。
關于ASP.NET MVC5網(wǎng)站開發(fā)一系列的文章整理馬上就接近尾聲了,希望這些文章可以幫助到大家更好地開發(fā)ASP.NET MVC5網(wǎng)站。
- ASP.NET MVC5網(wǎng)站開發(fā)之登錄、驗證和注銷管理員篇1(六)
- ASP.NET MVC5網(wǎng)站開發(fā)之展示層架構(五)
- ASP.NET MVC5網(wǎng)站開發(fā)管理列表、回復及刪除(十三)
- ASP.NET?MVC5網(wǎng)站開發(fā)顯示文章列表(九)
- ASP.NET MVC5網(wǎng)站開發(fā)添加文章(八)
- ASP.NET MVC5網(wǎng)站開發(fā)用戶修改資料和密碼(六)
- ASP.NET?MVC5網(wǎng)站開發(fā)用戶登錄、注銷(五)
- ASP.NET?MVC5?網(wǎng)站開發(fā)框架模型、數(shù)據(jù)存儲、業(yè)務邏輯(三)
- ASP.NET MVC5網(wǎng)站開發(fā)項目框架(二)
- MVC4制作網(wǎng)站教程第四章 前臺欄目瀏覽4.5
相關文章
asp.net 動態(tài)創(chuàng)建TextBox控件及狀態(tài)數(shù)據(jù)如何加載
接著上文Asp.net TextBox的TextChanged事件你真的清楚嗎?這里我們來說說狀態(tài)數(shù)據(jù)時如何加載的,需要的朋友可以參考下2012-12-12關于visual studio 2012 update 2中的新功能介紹
本篇文章小編為大家介紹,關于visual studio 2012 update 2中的新功能介紹說明。需要的朋友參考下2013-04-04Linux安裝.Net core 環(huán)境并運行項目的方法
這篇文章主要介紹了Linux安裝.Net core 環(huán)境并運行項目,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-08-08.Net?Api?中使用Elasticsearch存儲文檔的方法
Elasticsearch 是一個分布式、高擴展、高實時的搜索與數(shù)據(jù)分析引擎,在C# 的環(huán)境中,有一個Es的官方拓展包Nest,可以讓我們方便快捷的使用上Es數(shù)據(jù)庫,本文重點給大家介紹.Net?Api?中使用Elasticsearch存儲文檔的方法,感興趣的朋友一起看看吧2022-01-01Asp.Net 文件操作基類(讀取,刪除,批量拷貝,刪除,寫入,獲取文件夾大小,文件屬性,遍歷目錄)
Asp.Net 文件操作基類(讀取,刪除,批量拷貝,刪除,寫入,獲取文件夾大小,文件屬性,遍歷目錄),需要的朋友可以參考下2008-07-07uni-app結合.NET?7實現(xiàn)微信小程序訂閱消息推送
本文主要介紹了uni-app結合.NET?7實現(xiàn)微信小程序訂閱消息推送,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2023-02-02DataSet 添加數(shù)據(jù)集、行、列、主鍵和外鍵等操作示例
DataSet 添加數(shù)據(jù)集、行、列、主鍵和外鍵等操作示例...2007-03-03