diff --git a/src/BCards.Web/Controllers/AdminController.cs b/src/BCards.Web/Controllers/AdminController.cs index f724852..5c82e6c 100644 --- a/src/BCards.Web/Controllers/AdminController.cs +++ b/src/BCards.Web/Controllers/AdminController.cs @@ -457,32 +457,17 @@ public class AdminController : Controller } [HttpPost] - [Route("DeletePage/{id}")] - public async Task DeletePage(string id) + public async Task DeletePage() { var user = await _authService.GetCurrentUserAsync(User); if (user == null) return RedirectToAction("Login", "Auth"); - try + var userPage = await _userPageService.GetUserPageAsync(user.Id); + if (userPage != null) { - // Verificar se a página existe e pertence ao usuário - var page = await _userPageService.GetPageByIdAsync(id); - if (page == null || page.UserId != user.Id) - { - TempData["Error"] = "Página não encontrada ou você não tem permissão para excluí-la."; - return RedirectToAction("Dashboard"); - } - - // Excluir a página - await _userPageService.DeletePageAsync(id); - - TempData["Success"] = $"Página '{page.DisplayName}' excluída com sucesso!"; - } - catch (Exception ex) - { - _logger.LogError(ex, "Erro ao excluir página com ID: {PageId}", id); - TempData["Error"] = "Erro ao excluir página. Tente novamente."; + await _userPageService.DeletePageAsync(userPage.Id); + TempData["Success"] = "Página excluída com sucesso!"; } return RedirectToAction("Dashboard"); diff --git a/src/BCards.Web/Views/Admin/Dashboard.cshtml b/src/BCards.Web/Views/Admin/Dashboard.cshtml index 5b9dd84..1b2b3a8 100644 --- a/src/BCards.Web/Views/Admin/Dashboard.cshtml +++ b/src/BCards.Web/Views/Admin/Dashboard.cshtml @@ -15,7 +15,7 @@
@if (!string.IsNullOrEmpty(Model.CurrentUser.ProfileImage)) { - @Model.CurrentUser.Name }
@@ -27,19 +27,10 @@ {
-
- - - -
@(page.DisplayName)
+
+
@(page.DisplayName)

@(page.Category)/@(page.Slug)

- +
@switch (page.Status) { @@ -71,11 +62,11 @@
} - +
- Editar - Ver
@@ -85,7 +76,7 @@
} - + @if (Model.CanCreateNewPage) { @@ -95,7 +86,7 @@
Criar Nova Página
- Começar
@@ -129,7 +120,7 @@
- Limite atingido! + Limite atingido! Você já criou o máximo de @Model.CurrentPlan.MaxPages página(s) para seu plano atual. Fazer upgrade
@@ -150,7 +141,7 @@
@Model.CurrentPlan.Name
- + @if (Model.CurrentPlan.Type == BCards.Web.Models.PlanType.Trial) {

@@ -162,7 +153,7 @@ {

R$ @Model.CurrentPlan.Price.ToString("F2")/mês

} - +
Páginas @@ -170,14 +161,14 @@
@{ - var pagesPercentage = Model.CurrentPlan.MaxPages > 0 ? - (double)Model.UserPages.Count / Model.CurrentPlan.MaxPages * 100 : 0; + var pagesPercentage = Model.CurrentPlan.MaxPages > 0 ? + (double)Model.UserPages.Count / Model.CurrentPlan.MaxPages * 100 : 0; } -
- +
Links por página: @(Model.CurrentPlan.MaxLinksPerPage == int.MaxValue ? "Ilimitado" : Model.CurrentPlan.MaxLinksPerPage.ToString()) @@ -190,7 +181,7 @@ Temas customizáveis: @(Model.CurrentPlan.AllowsCustomThemes ? "✅" : "❌")
- + @if (Model.CurrentPlan.Type == BCards.Web.Models.PlanType.Trial) { @@ -280,46 +271,6 @@
- -@foreach (var page in Model.UserPages) -{ - -} - @if (TempData["Success"] != null) {