Ejemplo n.º 1
0
        public async Task <List <Dashboard> > GetDashboardsFilteredByPrivilege(string userID)
        {
            /* todo pass User into the managers instead of looking up id? */
            var currentUser = await _userManager.FindByIdAsync(userID);

            if (await _userManager.IsInRoleAsync(currentUser, Constants.AdminRole)) // first check for admin
            {
                return(GetDashboards());                                            // if user is admin, they get all the goodies
            }


            List <Dashboard> result = new List <Dashboard>();

            List <Dashboard> dashboards = accessor.GetActiveDashboards().OrderBy(x => x.SortOrder).ToList(); // grab dashboards
            List <string>    dashPriv   = accessor.GetDashPrivilegesForUser(userID);                         // grab dashboardIDs of dashboards the user can edit

            foreach (var dash in dashboards)                                                                 // filter out so that we only get dashboards the use can edit
            {
                if (dashPriv.Contains(dash.DashboardID.ToString()))
                {
                    result.Add(dash);
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
 public List <string> GetDashPrivilegesForUser(string id)
 {
     return(accessor.GetDashPrivilegesForUser(id));
 }