【问题标题】:Display list of data on the basis of roles in MVC asp.net identity根据 MVC asp.net 身份中的角色显示数据列表
【发布时间】:2015-01-05 16:55:28
【问题描述】:
我有一个列表,显示管理员和用户上传的所有视频,但我想应用一些条件来单独显示用户和管理员上传列表(只想根据角色分开列表)。
我该怎么做?
这是显示所有视频的代码
public ActionResult Index()
{
var videos = db.Videos.Include(v => v.Artist).Include(v => v.Category);
return View(videos.ToList());
}
【问题讨论】:
标签:
asp.net-mvc
actionresult
【解决方案1】:
这里是视频类
public class Video
{
public int Id { get; set; }
public virtual Category Category { get; set; }
public int CategoryId { get; set; }
public virtual Artist Artist { get; set; }
public int ArtistId { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string Length { get; set; }
public string Keywords { get; set; }
public string format { get; set; }
public string Language { get; set; }
public string URL { get; set; }
public string Image { get; set; }
public string UserId { get; set; }
public bool isblock { get; set; }
public virtual ApplicationUser ApplicationUser { get; set; }
public virtual ICollection<Comment> comments { get; set; }
public virtual ICollection<Like> likes { get; set; }
public virtual ICollection<HitCounter> Views { get; set; }
}