Пример #1
0
        public async Task <IActionResult> Enable(string id)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageTenants))
            {
                return(Unauthorized());
            }

            if (!IsDefaultShell())
            {
                return(Unauthorized());
            }

            var shellContext = _orchardHost
                               .ListShellContexts()
                               .OrderBy(x => x.Settings.Name)
                               .Where(x => String.Equals(x.Settings.Name, id, StringComparison.OrdinalIgnoreCase))
                               .FirstOrDefault();

            if (shellContext == null)
            {
                return(NotFound());
            }

            var shellSettings = shellContext.Settings;

            if (shellSettings.State != TenantState.Disabled)
            {
                _notifier.Error(H["You can only enable a Disabled shell."]);
            }

            shellSettings.State = TenantState.Running;
            _orchardHost.UpdateShellSettings(shellSettings);

            return(RedirectToAction(nameof(Index)));
        }