feat/live-preview #1
@ -457,32 +457,17 @@ public class AdminController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("DeletePage/{id}")]
|
public async Task<IActionResult> DeletePage()
|
||||||
public async Task<IActionResult> DeletePage(string id)
|
|
||||||
{
|
{
|
||||||
var user = await _authService.GetCurrentUserAsync(User);
|
var user = await _authService.GetCurrentUserAsync(User);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
return RedirectToAction("Login", "Auth");
|
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
|
await _userPageService.DeletePageAsync(userPage.Id);
|
||||||
var page = await _userPageService.GetPageByIdAsync(id);
|
TempData["Success"] = "Página excluída com sucesso!";
|
||||||
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");
|
return RedirectToAction("Dashboard");
|
||||||
|
|||||||
@ -27,17 +27,8 @@
|
|||||||
{
|
{
|
||||||
<div class="col-md-6 col-lg-4 mb-3">
|
<div class="col-md-6 col-lg-4 mb-3">
|
||||||
<div class="card h-100 @(page.Status == BCards.Web.ViewModels.PageStatus.Active ? "" : "border-warning")">
|
<div class="card h-100 @(page.Status == BCards.Web.ViewModels.PageStatus.Active ? "" : "border-warning")">
|
||||||
<div class="card-body position-relative" style="padding-top: 20px;">
|
<div class="card-body">
|
||||||
<!-- Botão de excluir no canto superior direito -->
|
<h6 class="card-title">@(page.DisplayName)</h6>
|
||||||
<button class="btn btn-sm btn-outline-danger position-absolute"
|
|
||||||
style="top: 8px; right: 8px; z-index: 10; padding: 4px 6px;"
|
|
||||||
data-bs-toggle="modal"
|
|
||||||
data-bs-target="#deleteModal-@(page.Id)"
|
|
||||||
title="Excluir página">
|
|
||||||
<i class="fas fa-trash-alt" style="font-size: 11px;"></i>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<h6 class="card-title" style="padding-right: 35px;">@(page.DisplayName)</h6>
|
|
||||||
<p class="text-muted small mb-2">@(page.Category)/@(page.Slug)</p>
|
<p class="text-muted small mb-2">@(page.Category)/@(page.Slug)</p>
|
||||||
|
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
@ -171,7 +162,7 @@
|
|||||||
<div class="progress" style="height: 6px;">
|
<div class="progress" style="height: 6px;">
|
||||||
@{
|
@{
|
||||||
var pagesPercentage = Model.CurrentPlan.MaxPages > 0 ?
|
var pagesPercentage = Model.CurrentPlan.MaxPages > 0 ?
|
||||||
(double)Model.UserPages.Count / Model.CurrentPlan.MaxPages * 100 : 0;
|
(double)Model.UserPages.Count / Model.CurrentPlan.MaxPages * 100 : 0;
|
||||||
}
|
}
|
||||||
<div class="progress-bar @(pagesPercentage >= 80 ? "bg-warning" : "bg-primary")"
|
<div class="progress-bar @(pagesPercentage >= 80 ? "bg-warning" : "bg-primary")"
|
||||||
style="width: @pagesPercentage%"></div>
|
style="width: @pagesPercentage%"></div>
|
||||||
@ -280,46 +271,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Modais de Confirmação para Excluir Páginas -->
|
|
||||||
@foreach (var page in Model.UserPages)
|
|
||||||
{
|
|
||||||
<div class="modal fade" id="deleteModal-@(page.Id)" tabindex="-1" aria-labelledby="deleteModalLabel-@(page.Id)" aria-hidden="true">
|
|
||||||
<div class="modal-dialog modal-dialog-centered">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header border-bottom-0">
|
|
||||||
<h5 class="modal-title" id="deleteModalLabel-@(page.Id)">
|
|
||||||
<i class="fas fa-exclamation-triangle text-warning me-2"></i>
|
|
||||||
Confirmar Exclusão
|
|
||||||
</h5>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body text-center">
|
|
||||||
<div class="mb-3">
|
|
||||||
<i class="fas fa-trash-alt fa-3x text-danger mb-3"></i>
|
|
||||||
</div>
|
|
||||||
<h6>Tem certeza que deseja excluir a página <strong>"@(page.DisplayName)"</strong>?</h6>
|
|
||||||
<p class="text-muted small mb-0">
|
|
||||||
Esta ação não pode ser desfeita. Todos os dados da página, incluindo estatísticas, serão perdidos permanentemente.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer border-top-0 justify-content-center">
|
|
||||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
|
|
||||||
<i class="fas fa-times me-2"></i>
|
|
||||||
Cancelar
|
|
||||||
</button>
|
|
||||||
<form method="post" action="@Url.Action("DeletePage", new { id = page.Id })" class="d-inline">
|
|
||||||
@Html.AntiForgeryToken()
|
|
||||||
<button type="submit" class="btn btn-danger">
|
|
||||||
<i class="fas fa-trash-alt me-2"></i>
|
|
||||||
Excluir Página
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
@if (TempData["Success"] != null)
|
@if (TempData["Success"] != null)
|
||||||
{
|
{
|
||||||
<div class="toast-container position-fixed top-0 end-0 p-3">
|
<div class="toast-container position-fixed top-0 end-0 p-3">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user