Files
WorkManagementTool/WorkManagementTool/Components/Project/ProjectDeletion.razor
Namu 9c5d24354a
Some checks failed
build / build (push) Failing after 47s
SonarQube Scan / SonarQube Trigger (push) Successful in 34s
Feat: Add project deletion
2026-01-06 17:17:27 +01:00

31 lines
775 B
Plaintext

@using Microsoft.AspNetCore.Authorization
@using WorkManagementTool.Data.Entities;
@using WorkManagementTool.Services;
@inject ProjectService ProjectService
@attribute [Authorize]
@rendermode InteractiveServer
<button class="btn btn-danger" @onclick="DeleteProjectAsync">-</button>
@code {
[Parameter]
public int ProjectId { get; set; }
public async Task DeleteProjectAsync(MouseEventArgs e)
{
var project = await ProjectService.GetProjectByIdAsync(ProjectId);
if (project is null)
throw new ArgumentNullException(nameof(project));
await ProjectService.DeleteProjectAsync(project.Id);
await OnDeleted.InvokeAsync(ProjectId);
}
[Parameter]
public EventCallback<int> OnDeleted { get; set; }
}