public bool UserCanView(CMSDataContext db) { if (db.FromBatch) { return(true); } if (!VisibilityRoles.HasValue()) { return(true); } var a = VisibilityRoles.SplitStr(","); var user = HttpContext.Current.User; return(a.Any(role => user.IsInRole(role.Trim()))); }
public IEnumerable <SelectListItem> Roles() { var q = from r in DbUtil.Db.Roles orderby r.RoleName select new SelectListItem { Value = r.RoleName, Text = r.RoleName }; var list = q.ToList(); foreach (var item in list.Where(item => VisibilityRoles.Contains(item.Text))) { item.Selected = true; } return(list); }
public bool UserCanView() { if (!VisibilityRoles.HasValue()) { return(true); } var a = VisibilityRoles.SplitStr(","); var user = HttpContext.Current.User; foreach (var role in a) { if (user.IsInRole(role.Trim())) { return(true); } } return(false); }