Display list of data on the basis of roles in MVC asp.net identity

只愿长相守 提交于 2019-12-12 01:53:23

问题


I have a list which shows all the videos uploaded by Admin and Users, But I want to apply some condition to individually display User and Admin uploads list (just want to separate list on the basis of roles). How can i do it?

This is the code which displays all the Videos

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

回答1:


Here is the video class

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


来源:https://stackoverflow.com/questions/27784211/display-list-of-data-on-the-basis-of-roles-in-mvc-asp-net-identity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!