diff --git a/src/BCards.Web/Controllers/AdminController.cs b/src/BCards.Web/Controllers/AdminController.cs index 5c82e6c..f724852 100644 --- a/src/BCards.Web/Controllers/AdminController.cs +++ b/src/BCards.Web/Controllers/AdminController.cs @@ -457,17 +457,32 @@ public class AdminController : Controller } [HttpPost] - public async Task DeletePage() + [Route("DeletePage/{id}")] + public async Task DeletePage(string id) { var user = await _authService.GetCurrentUserAsync(User); if (user == null) return RedirectToAction("Login", "Auth"); - var userPage = await _userPageService.GetUserPageAsync(user.Id); - if (userPage != null) + try { - await _userPageService.DeletePageAsync(userPage.Id); - TempData["Success"] = "Página excluída com sucesso!"; + // 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."; } return RedirectToAction("Dashboard"); diff --git a/src/BCards.Web/Views/Admin/Dashboard.cshtml b/src/BCards.Web/Views/Admin/Dashboard.cshtml index 1b2b3a8..5b9dd84 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,10 +27,19 @@ {
-
-
@(page.DisplayName)
+
+ + + +
@(page.DisplayName)

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

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

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

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

} - +
Páginas @@ -161,14 +170,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()) @@ -181,7 +190,7 @@ Temas customizáveis: @(Model.CurrentPlan.AllowsCustomThemes ? "✅" : "❌")
- + @if (Model.CurrentPlan.Type == BCards.Web.Models.PlanType.Trial) { @@ -271,6 +280,46 @@
+ +@foreach (var page in Model.UserPages) +{ + +} + @if (TempData["Success"] != null) {