2015-11-14 92 views
0

類Task.cs保持任務優先級(ASP.NET MVC)

public class Task 
{ 
    [Required] 
    public int Id { get; set; } 

    [Required] 
    public string Title { get; set; } 

    public string Description { get; set; } 

    public int Priority { get; set; } 

    [Required] 
    public string DateCreation { get; set; } 

    public string DateTarget { get; set; } 

    public bool IsActive { get; set; } 

    public bool IsDeleted { get; set; } 

} 

及其財產Priority可以有4個不同的值,最好的方法:0 - 低,1 - 正常, 2 - 高,3 - 極端。 保留這些值的最佳方法是什麼?我應該創建class Priority,還是隻在我的數據庫中創建表Priority,並設置這些值或使用List也許?
這是我第一次嘗試創建Asp.Net MVC應用程序,所以我不確定哪種方法更好。

+3

如果值是不可能改變的,可考慮將它的'enum' –

+0

你是問,你應該保持工作的選擇,使他們可以在視圖例如被渲染落下? – StuartLC

+0

你可以看看'enum' https://msdn.microsoft.com/en-us/library/sbbt4032.aspx – Amitd

回答

2

正如斯蒂芬·馬克說,你需要使用enum.You可以在一個層,從其他層訪問(UI,DAL,服務)創建枚舉。