根据MVC asp.net标识中的角色显示数据列表

时间:2015-01-05 16:55:28

标签: asp.net-mvc actionresult

我有一个列表,显示管理员和用户上传的所有视频,但我想应用一些条件来单独显示用户和管理员上传列表(只是想根据角色分开列表)。 我该怎么做?

这是显示所有视频的代码

public ActionResult Index()
    {
        var videos = db.Videos.Include(v => v.Artist).Include(v => v.Category);
        return View(videos.ToList());
    }

1 个答案:

答案 0 :(得分:0)

这是视频课

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; }   
 }