forked from thinktecture/Thinktecture.Blazor
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathConferences.razor.cs
49 lines (42 loc) · 1.91 KB
/
Conferences.razor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using PatrickJahr.Blazor.GrpcDevTools.Client.Features.Shared.Dialogs;
using PatrickJahr.Blazor.GrpcDevTools.Shared.DTO;
using PatrickJahr.Blazor.GrpcDevTools.Shared.Services;
using Microsoft.AspNetCore.Components;
using MudBlazor;
namespace PatrickJahr.Blazor.GrpcDevTools.Client.Features.Conferences
{
public partial class Conferences
{
[Inject] private IConferencesService _conferencesService { get; set; } = default!;
[Inject] private NavigationManager _navigationManager { get; set; } = default!;
[Inject] private IDialogService _dialogService { get; set; } = default!;
private List<ConferenceOverview>? _conferences;
protected override async Task OnInitializedAsync()
{
_conferences = (await _conferencesService.ListConferencesAsync()).ToList();
await base.OnInitializedAsync();
}
private void AddConference()
{
_navigationManager.NavigateTo($"/conferences/new");
}
private void EditConference(Guid id)
{
_navigationManager.NavigateTo($"/conferences/edit/{id}");
}
private async Task DeleteConference(Guid id, string title)
{
var parameters = new DialogParameters();
parameters.Add(nameof(ConfirmDialog.ContentText), $"Are you sure you want to remove {title}?");
parameters.Add(nameof(ConfirmDialog.ButtonText), "Yes");
parameters.Add(nameof(ConfirmDialog.Color), Color.Success);
var reference = _dialogService.Show<ConfirmDialog>("Delete", parameters);
var result = await reference.Result;
if (result.Data is bool confirmed && confirmed)
{
await _conferencesService.DeleteConferenceAsync(new ConferenceDetailsRequest() { ID = id });
_conferences = (await _conferencesService.ListConferencesAsync()).ToList();
}
}
}
}