【问题标题】: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());
    }

【问题讨论】:

  • 视频表是否有用户角色列?
  • 不,在视频表中只有用户 ID 列,而不是角色
  • 您是否在应用程序中设置角色身份验证。
  • 可以分享一下“视频”课吗?

标签: 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; }   
 }

【讨论】:

    猜你喜欢
    • 2020-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-21
    • 1970-01-01
    • 2014-08-19
    • 1970-01-01
    相关资源
    最近更新 更多