Added user domain delete

This commit is contained in:
Marcel Baumgartner
2023-06-11 22:10:28 +02:00
parent c2d0ab4b1b
commit c2949b4773

View File

@@ -1,5 +1,4 @@
@page "/domain/{Id:int}" @page "/domain/{Id:int}"
@using Moonlight.App.Services.Sessions
@using Moonlight.App.Repositories.Domains @using Moonlight.App.Repositories.Domains
@using Moonlight.App.Database.Entities @using Moonlight.App.Database.Entities
@using Microsoft.EntityFrameworkCore @using Microsoft.EntityFrameworkCore
@@ -11,6 +10,8 @@
@inject DomainRepository DomainRepository @inject DomainRepository DomainRepository
@inject DomainService DomainService @inject DomainService DomainService
@inject SmartTranslateService SmartTranslateService @inject SmartTranslateService SmartTranslateService
@inject NavigationManager NavigationManager
@inject AlertService AlertService
<LazyLoader Load="Load"> <LazyLoader Load="Load">
@if (Domain == null) @if (Domain == null)
@@ -28,6 +29,13 @@
<span class="card-title"> <span class="card-title">
<TL>DNS records for</TL><span class="ms-3">@(domainNameBuilt)</span> <TL>DNS records for</TL><span class="ms-3">@(domainNameBuilt)</span>
</span> </span>
<div class="card-toolbar">
<WButton Text="@(SmartTranslateService.Translate("Delete domain"))"
WorkingText="@(SmartTranslateService.Translate("Deleting"))"
CssClasses="btn-danger"
OnClick="Delete">
</WButton>
</div>
</div> </div>
<div class="mt-5"></div> <div class="mt-5"></div>
<LazyLoader @ref="DnsLazyLoader" Load="LoadDnsRecords"> <LazyLoader @ref="DnsLazyLoader" Load="LoadDnsRecords">
@@ -240,4 +248,13 @@
await DomainService.DeleteDnsRecord(Domain!, record); await DomainService.DeleteDnsRecord(Domain!, record);
await DnsLazyLoader.Reload(); await DnsLazyLoader.Reload();
} }
private async Task Delete()
{
if (await AlertService.ConfirmMath())
{
await DomainService.Delete(Domain!);
NavigationManager.NavigateTo("/domains");
}
}
} }