Пример #1
0
        private async Task DeleteSite(Alias alias)
        {
            try
            {
                if (alias.SiteId != PageState.Site.SiteId || alias.TenantId != PageState.Site.TenantId)
                {
                    SiteService.SetAlias(alias);
                    await SiteService.DeleteSiteAsync(alias.SiteId);
                    await Log(alias, LogLevel.Information, "", null, "Site Deleted {SiteId}", alias.SiteId);

                    var aliases = await AliasService.GetAliasesAsync();

                    foreach (Alias a in aliases.Where(item => item.SiteId == alias.SiteId && item.TenantId == alias.TenantId))
                    {
                        await AliasService.DeleteAliasAsync(a.AliasId);
                    }

                    NavigationManager.NavigateTo(NavigateUrl());
                }
                else
                {
                    AddModuleMessage("You Can Not Delete The Current Site", MessageType.Warning);
                }
            }
            catch (Exception ex)
            {
                await Log(alias, LogLevel.Error, "", ex, "Error Deleting Site {SiteId} {Error}", alias.SiteId, ex.Message);

                AddModuleMessage("Error Deleting Site", MessageType.Error);
            }
        }