Exemple #1
0
        public static AppDto FromApp(IAppEntity app, string userId, PermissionSet userPermissions, IAppPlansProvider plans, ApiController controller)
        {
            var permissions = GetPermissions(app, userId, userPermissions);

            var result = SimpleMapper.Map(app, new AppDto());

            result.Permissions = permissions.ToIds();
            result.PlanName    = plans.GetPlanForApp(app)?.Name;

            if (controller.Includes(AllPermissions.ForApp(AllPermissions.AppApi, app.Name), permissions))
            {
                result.CanAccessApi = true;
            }

            if (controller.Includes(AllPermissions.ForApp(AllPermissions.AppContents, app.Name, "*"), permissions))
            {
                result.CanAccessContent = true;
            }

            if (controller.HasPermission(AllPermissions.AppPlansChange, app.Name))
            {
                result.PlanUpgrade = plans.GetPlanUpgradeForApp(app)?.Name;
            }

            return(result.CreateLinks(controller, permissions));
        }