Skip to content

Commit

Permalink
(#57) add option of deleting an event
Browse files Browse the repository at this point in the history
  • Loading branch information
an2508374 committed May 16, 2024
1 parent baa3c4d commit f4120ca
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
6 changes: 6 additions & 0 deletions MiniSpace.Web/src/MiniSpace.Web/Areas/Events/EventsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ public Task<HttpResponse<object>> UpdateEventAsync(Guid eventId, string name, Gu
capacity, fee, category, publishDate});
}

public Task DeleteEventAsync(Guid eventId)
{
_httpClient.SetAccessToken(_identityService.JwtDto.AccessToken);
return _httpClient.DeleteAsync($"events/{eventId}");
}

public Task SignUpToEventAsync(Guid eventId, Guid studentId)
{
_httpClient.SetAccessToken(_identityService.JwtDto.AccessToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Task<HttpResponse<object>> UpdateEventAsync(Guid eventId, string name, Guid orga
string startDate, string endDate, string buildingName, string street, string buildingNumber,
string apartmentNumber, string city, string zipCode, string description, int capacity, decimal fee,
string category, string publishDate);
Task DeleteEventAsync(Guid eventId);
Task SignUpToEventAsync(Guid eventId, Guid studentId);
Task CancelSignUpToEventAsync(Guid eventId, Guid studentId);
Task ShowInterestInEventAsync(Guid eventId, Guid studentId);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@page "/events/{EventId}/delete"
@using MiniSpace.Web.Areas.Events
@using Radzen
@inject DialogService DialogService
@inject IEventsService EventsService
@inject NavigationManager NavigationManager

<RadzenStack Gap="1rem">

<RadzenStack Gap="1rem" Orientation="Orientation.Vertical" JustifyContent="JustifyContent.SpaceBetween" Style="height: 100%;">
<RadzenStack Orientation="Orientation.Horizontal" JustifyContent="JustifyContent.Center" Gap="0.5rem">
<RadzenButton Click="@(() => DeleteEvent(EventId))" Variant="Variant.Flat" Text="Delete" Style="width: 100px"/>
<RadzenButton Click="@(() => DialogService.Close(true))" Variant="Variant.Flat" Text="Cancel" Style="width: 100px"/>
</RadzenStack>
</RadzenStack>
</RadzenStack>

@code {
[Parameter]
public Guid EventId { get; set; }

protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
}

private async void DeleteEvent(Guid eventId)
{
await EventsService.DeleteEventAsync(eventId);
DialogService.Close(true);
NavigationManager.NavigateTo("/events/organize");
}
}
14 changes: 13 additions & 1 deletion MiniSpace.Web/src/MiniSpace.Web/Pages/Events/Event.razor
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@
<RadzenStack Orientation="Orientation.Horizontal" JustifyContent="JustifyContent.Center" Gap="0.5rem">
<RadzenButton Size="ButtonSize.Medium" Text="Update event" ButtonStyle="ButtonStyle.Secondary"
Click="@(() => NavigationManager.NavigateTo($"/events/{ev.Id}/update"))" />
<RadzenButton Size="ButtonSize.Medium" Text="Delete event" ButtonStyle="ButtonStyle.Warning" />
<RadzenButton Size="ButtonSize.Medium" Text="Delete event" ButtonStyle="ButtonStyle.Warning"
Click="@(() => OpenDeleteEventDialog(ev.Id))" />
</RadzenStack>

<RadzenStack Orientation="Orientation.Horizontal" JustifyContent="JustifyContent.Center" Gap="0.5rem">
Expand Down Expand Up @@ -334,6 +335,17 @@
});
}

private async Task OpenDeleteEventDialog(Guid postId)
{
await DialogService.OpenAsync<DeleteEventDialog>("Are you sure? This action cannot be undone!",
new Dictionary<string, object>() { {"EventId", new Guid(EventId) } },
new DialogOptions()
{
Width = "500px", Height = "100px", Resizable = true, Draggable = true,
AutoFocusFirstElement = false
});
}

private async Task OpenParticipantDetailsDialog(ParticipantDto participantDto, string term)
{
await DialogService.OpenAsync<ParticipantDetailsDialog>($"Details of the {term}:",
Expand Down

0 comments on commit f4120ca

Please sign in to comment.