服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|JAVA教程|ASP教程|

服务器之家 - 编程语言 - ASP.NET教程 - ASP.NET MVC5网站开发咨询管理的架构(十一)

ASP.NET MVC5网站开发咨询管理的架构(十一)

2019-12-23 13:38洞庭夕照 ASP.NET教程

这篇文章主要介绍了ASP.NET MVC5网站开发咨询管理的架构,需要的朋友可以参考下

一、总体说明
1、实现功能

ASP.NET,MVC5,网站开发

2、类图

ASP.NET,MVC5,网站开发

由于文章部分把大部分类都是实现了,这里仅多了一个Consultation类。
二、创建咨询模型类
在Ninesky.Models项目添加类Consultation(咨询模型),该模型跟Article类似都是CommonModel的扩展。
1、添加Consultation类。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.ComponentModel.DataAnnotations;
 
namespace Ninesky.Models
{
  /// <summary>
  /// 咨询模型
  /// <remarks>创建: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}个数字")]
    public string QQ { get; set; }
 
    /// <summary>
    /// Email地址
    /// </summary>
    [Display(Name = "Email地址")]
    [DataType(DataType.EmailAddress,ErrorMessage="必须输入正确的Email地址")]
    public string Email { get; set; }
 
    /// <summary>
    /// 内容
    /// </summary>
    [Display(Name = "内容")]
    [Required(ErrorMessage = "必填")]
    [StringLength(1000, ErrorMessage = "必须少于{0}个字符")]
    public string Content { get; set; }
 
    /// <summary>
    /// 是否公开
    /// </summary>
    [Display(Name = "是否公开")]
    public bool IsPublic { get; set; }
 
    /// <summary>
    /// 回复内容
    /// </summary>
    [Display(Name = "回复内容")]
    public string ReplyContent { get; set; }
 
    /// <summary>
    /// 回复时间
    /// </summary>
    [Display(Name = "回复时间")]
    public Nullable<DateTime> ReplyTime { get; set; }
  }
}

2、在CommonModel里添加外键

ASP.NET,MVC5,网站开发

三、添加控制器
打开Ninesky.Web项目在Member区域添加Consultation控制器

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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,内容比较简单。

关于ASP.NET MVC5网站开发一系列的文章整理马上就接近尾声了,希望这些文章可以帮助到大家更好地开发ASP.NET MVC5网站。

延伸 · 阅读

精彩推荐