技术开发 频道

基于MVC框架开发Web论坛之测试篇

  三、 创建Message类

  首先,我们需要创建一个消息类,它用于描述一条提交到论坛的消息。列表2提供了有关这个类的完整代码。
列表2–Models\Message.cs
 

using System;

namespace MvcForums.Models
{
    
public class Message
    {
        
public Message()
        { }

        
public Message(int id, int? parentId, string author, string subject, string body)
        {
            this.Id
= id;
            this.ParentId
= parentId;
            this.Author
= author;
            this.Subject
= subject;
            this.Body
= body;
        }

        
public int Id { get; set; }
        
public int? ParentId { get; set; }
        
public string Author { get; set; }
        
public string Subject { get; set; }
        
public string Body { get; set; }
        
public DateTime EntryDate { get; set; }
    }
}
1
相关文章