好幾天沒時間寫了。今天有寫時間在學一點。
今天狀態(tài)也不是很好,暈暈沉沉的寫吧。
序
一、用戶
二、用戶組
三、欄目
3.1添加欄目
首先添加【CategoryController】控制器,
那么我想我的視圖里,首先顯示的應(yīng)該是欄目類型,這里應(yīng)該是一個下拉框,用戶可以選擇“一般欄目”,“單頁欄目”,“外部鏈接”。那么首先應(yīng)該在【CategoryController】添加一個屬性,用來返回欄目類型列表。
#region Attribute public List<SelectListItem> TypeSelectList { get { List<SelectListItem> _items = new List<SelectListItem>(); _items.Add(new SelectListItem { Text = CategoryType.一般欄目.ToString(), Value = ((int)CategoryType.一般欄目).ToString() }); _items.Add(new SelectListItem { Text = CategoryType.單頁欄目.ToString(), Value = ((int)CategoryType.單頁欄目).ToString() }); _items.Add(new SelectListItem { Text = CategoryType.外部鏈接.ToString(), Value = ((int)CategoryType.外部鏈接).ToString() }); return _items; } } #endregion其次,用戶應(yīng)該可以選擇內(nèi)容模型,內(nèi)容模型是什么?
內(nèi)容模型就是這個欄目下可以添加內(nèi)容的模型名稱?這個模型名稱對應(yīng)的就是Models中間的模型類。為了更好的表述在系統(tǒng)中添加模塊“Module ”的概念。模塊用來指系統(tǒng)中用來實現(xiàn)相應(yīng)功能的塊,想新聞模塊,文章模塊,留言模塊,圖片模塊,產(chǎn)品模塊,服務(wù)模塊等等,每個模塊對應(yīng)相應(yīng)的模型和控制器,用來實現(xiàn)設(shè)想中的功能。系統(tǒng)中預(yù)置的模塊用戶應(yīng)該可以設(shè)置啟用還是關(guān)閉。
第一應(yīng)該添加內(nèi)容模型類
using System.ComponentModel.DataAnnotations;namespace Ninesky.Models{ /// <summary> /// 內(nèi)容模塊 /// </summary> public class Module { [Key] public int ModuleId { get; set; } /// <summary> /// 模塊名稱 /// </summary> [Required(ErrorMessage="×")] [Display(Name="模塊名稱")] public string Name { get; set; } /// <summary> /// 模塊模型 /// </summary> [Required(ErrorMessage = "×")] [Display(Name = "模塊模型")] public string Model { get; set; } /// <summary> /// 啟用模塊 /// </summary> [Required(ErrorMessage = "×")] [Display(Name = "啟用模塊")] public bool Enable { get; set; } /// <summary> /// 說明 /// </summary> [Required(ErrorMessage = "×")] [Display(Name = "說明")] public string Description { get; set; } }}既然有模塊類,就應(yīng)該有模塊類的數(shù)據(jù)處理類ModuleRepository,這塊功能暫時留在后面來寫,先最簡單的實現(xiàn)List(bool enable)函數(shù)讓其能顯示模塊列表。
using Ninesky.Models;using System.Collections.Generic;using System.Linq;namespace Ninesky.Repository{ public class ModuleRepository { public IQueryable<Module> List(bool enable) { List<Module> _module = new List<Module>(); _module.Add(new Module { Name = "新聞模塊", Model = "News", Enable = true, Description = "新聞模塊" }); _module.Add(new Module { Name = "文章模塊", Model = "Article", Enable = true, Description = "文章模塊" }); return _module.AsQueryable(); } }}
新聞熱點
疑難解答
圖片精選