Ejemplo n.º 1
0
        protected override async Task <PermissionResult> CanAddAsync(Project value)
        {
            if (String.IsNullOrEmpty(value.Name))
            {
                return(PermissionResult.DenyWithMessage("Project name is required."));
            }

            if (!await IsProjectNameAvailableInternalAsync(value.OrganizationId, value.Name))
            {
                return(PermissionResult.DenyWithMessage("A project with this name already exists."));
            }

            if (!await _billingManager.CanAddProjectAsync(value))
            {
                return(PermissionResult.DenyWithPlanLimitReached("Please upgrade your plan to add additional projects."));
            }

            return(await base.CanAddAsync(value));
        }
        protected override async Task <PermissionResult> CanAddAsync(Organization value)
        {
            if (String.IsNullOrEmpty(value.Name))
            {
                return(PermissionResult.DenyWithMessage("Organization name is required."));
            }

            if (!await IsOrganizationNameAvailableInternalAsync(value.Name))
            {
                return(PermissionResult.DenyWithMessage("A organization with this name already exists."));
            }

            if (!await _billingManager.CanAddOrganizationAsync(CurrentUser))
            {
                return(PermissionResult.DenyWithPlanLimitReached("Please upgrade your plan to add an additional organization."));
            }

            return(await base.CanAddAsync(value));
        }