Delete(Guid id, string providerName)
{
+ var provider = await _providerRepository.GetByIdAsync(id);
+
+ if (provider is null)
+ {
+ return BadRequest("Provider does not exist");
+ }
+
+ if (provider.Status == ProviderStatusType.Pending)
+ {
+ await _providerService.DeleteAsync(provider);
+ return NoContent();
+ }
+
if (string.IsNullOrWhiteSpace(providerName))
{
return BadRequest("Invalid provider name");
@@ -482,13 +495,6 @@ public class ProvidersController : Controller
return BadRequest("You must unlink all clients before you can delete a provider");
}
- var provider = await _providerRepository.GetByIdAsync(id);
-
- if (provider is null)
- {
- return BadRequest("Provider does not exist");
- }
-
if (!string.Equals(providerName.Trim(), provider.DisplayName(), StringComparison.OrdinalIgnoreCase))
{
return BadRequest("Invalid provider name");
diff --git a/src/Admin/AdminConsole/Views/Providers/Edit.cshtml b/src/Admin/AdminConsole/Views/Providers/Edit.cshtml
index ce215e1575..d2a9ed1f62 100644
--- a/src/Admin/AdminConsole/Views/Providers/Edit.cshtml
+++ b/src/Admin/AdminConsole/Views/Providers/Edit.cshtml
@@ -183,17 +183,29 @@
Delete provider
-
-
- This action is permanent and irreversible. Enter the provider name to complete deletion of the provider and associated data.
-
-
-
+
+ @if (Model.Provider.Status == ProviderStatusType.Pending)
+ {
+
+
+ This action is permanent and irreversible.
+
+
+ }
+ else
+ {
+
+
+ This action is permanent and irreversible. Enter the provider name to complete deletion of the provider and associated data.
+
+
+
+ }