コード例 #1
0
        public virtual async Task <Versioned <PermissionsForClientViews> > PermissionsForClient(CancellationToken cancellation)
        {
            // Retrieve the user permissions and their current version
            var(version, permissions) = await _repo.Permissions__Load(cancellation);

            // Arrange the permission in a DTO that is easy for clients to consume
            var permissionsForClient = new PermissionsForClientViews();

            foreach (var gView in permissions.GroupBy(e => e.View))
            {
                string view = gView.Key;
                Dictionary <string, bool> viewActions = gView
                                                        .GroupBy(e => e.Action)
                                                        .ToDictionary(g => g.Key, g => true);

                permissionsForClient[view] = viewActions;
            }

            // Tag the permissions for client with their current version
            var result = new Versioned <PermissionsForClientViews>
                         (
                version: version.ToString(),
                data: permissionsForClient
                         );

            // Return the result
            return(result);
        }
コード例 #2
0
        public async Task <Versioned <PermissionsForClient> > PermissionsForClient(CancellationToken cancellation)
        {
            // Retrieve the user permissions and their current version
            var(version, permissions, reportIds, dashboardIds) = await _repo.Permissions__Load(true, cancellation);

            // Arrange the permission in a DTO that is easy for clients to consume
            var views = new PermissionsForClientViews();

            foreach (var gView in permissions.GroupBy(e => e.View))
            {
                string view = gView.Key;
                Dictionary <string, bool> viewActions = gView
                                                        .GroupBy(e => e.Action)
                                                        .ToDictionary(g => g.Key, g => true);

                views[view] = viewActions;
            }

            // Include the report Ids and definitionIds
            var permissionsForClient = new PermissionsForClient
            {
                Views        = views,
                ReportIds    = reportIds,
                DashboardIds = dashboardIds
            };

            // Tag the permissions for client with their current version
            var result = new Versioned <PermissionsForClient>
                         (
                version: version.ToString(),
                data: permissionsForClient
                         );

            // Return the result
            return(result);
        }