From 28c6628afc9ad9440c85642e6e04a85929c1d581 Mon Sep 17 00:00:00 2001 From: Fenrikur <3359222+Fenrikur@users.noreply.github.com> Date: Sun, 25 Aug 2024 20:36:08 +0200 Subject: [PATCH 1/6] chore(artistalley): clean up RBAC for moderation --- .../ArtistAlleyApplicationDialog.razor | 49 ++++++------ .../Layout/NavMenu.razor | 5 +- .../Pages/ArtistAlleyModeration.razor | 77 ++++++++++--------- src/Eurofurence.App.Backoffice/Program.cs | 8 +- .../Controllers/ArtistsAlleyController.cs | 4 +- .../Identity/AuthorizationOptions.cs | 3 +- .../Identity/RolesClaimsTransformation.cs | 5 ++ 7 files changed, 88 insertions(+), 63 deletions(-) diff --git a/src/Eurofurence.App.Backoffice/Components/ArtistAlleyApplicationDialog.razor b/src/Eurofurence.App.Backoffice/Components/ArtistAlleyApplicationDialog.razor index 55a9d9ab..af9e5a71 100644 --- a/src/Eurofurence.App.Backoffice/Components/ArtistAlleyApplicationDialog.razor +++ b/src/Eurofurence.App.Backoffice/Components/ArtistAlleyApplicationDialog.razor @@ -13,29 +13,33 @@ { - + } - - - - - - - - + + + + + + + + @switch (Record.State) { case TableRegistrationRecord.RegistrationStateEnum.Pending: Pending - Approve - Reject + Approve + Reject @*Show the delete button only for admins*@ - + - Delete + + Delete break; @@ -63,10 +67,10 @@ private async Task DeleteRegistration() { DialogParameters dialog = new() - { - { x => x.ContentText, $"Are you sure you want to delete this application?" }, - { x => x.ActionButtonText, "Confirm" } - }; +{ +{ x => x.ContentText, $"Are you sure you want to delete this application?" }, +{ x => x.ActionButtonText, "Confirm" } +}; var options = new DialogOptions() { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall }; IDialogReference dialogRef = await DialogService.ShowAsync("Confirm", dialog, options); DialogResult result = await dialogRef.Result; @@ -86,17 +90,18 @@ private async void TryChangeRegistrationStatus(TableRegistrationRecord registrationRecord, bool reject) { DialogParameters dialog = new() - { - { x => x.ContentText, $"Are you sure you want to {(reject ? "reject" : "approve")} this application?" }, - { x => x.ActionButtonText, "Confirm" } - }; +{ +{ x => x.ContentText, $"Are you sure you want to {(reject ? "reject" : "approve")} this application?" }, +{ x => x.ActionButtonText, "Confirm" } +}; var options = new DialogOptions() { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall }; IDialogReference dialogRef = await DialogService.ShowAsync("Confirm", dialog, options); DialogResult result = await dialogRef.Result; if (!result.Canceled) { - var state = reject ? TableRegistrationRecord.RegistrationStateEnum.Rejected : TableRegistrationRecord.RegistrationStateEnum.Accepted; + var state = reject ? TableRegistrationRecord.RegistrationStateEnum.Rejected : + TableRegistrationRecord.RegistrationStateEnum.Accepted; await TableRegService.PutTableRegistrationStatusAsync(registrationRecord, state); Snackbar.Add($"Application was {(reject ? "rejected" : "approved")}."); diff --git a/src/Eurofurence.App.Backoffice/Layout/NavMenu.razor b/src/Eurofurence.App.Backoffice/Layout/NavMenu.razor index 58e30916..fda256e0 100644 --- a/src/Eurofurence.App.Backoffice/Layout/NavMenu.razor +++ b/src/Eurofurence.App.Backoffice/Layout/NavMenu.razor @@ -5,7 +5,8 @@ Images - - Artist Alley Moderation + + Artist Alley Moderation + \ No newline at end of file diff --git a/src/Eurofurence.App.Backoffice/Pages/ArtistAlleyModeration.razor b/src/Eurofurence.App.Backoffice/Pages/ArtistAlleyModeration.razor index c1371736..a8c97e87 100644 --- a/src/Eurofurence.App.Backoffice/Pages/ArtistAlleyModeration.razor +++ b/src/Eurofurence.App.Backoffice/Pages/ArtistAlleyModeration.razor @@ -5,7 +5,7 @@ @using Microsoft.AspNetCore.Authorization @using Color = MudBlazor.Color -@attribute [Authorize(Roles = "ArtistAlleyModerator")] +@attribute [Authorize(Policy = "RequireArtistAlleyModerator")] @inject IArtistAlleyService TableRegService @inject IDialogService DialogService @@ -14,30 +14,31 @@ Artist Alley Moderation - - + + + Adornment="Adornment.End" AdornmentIcon="@Icons.Material.Filled.Search" AdornmentColor="Color.Secondary" /> @* Table showing the basic informations for each application. More data of the applicant shall be visble an extra dialog - *@ - +*@ + - @if (context.Item.Image != null && !string.IsNullOrEmpty(context.Item.Image.Url)) + @if (context.Item.Image != null && !string.IsNullOrEmpty(context.Item.Image.Url)) { + Src="@context.Item.Image.Url" /> } - + @@ -51,12 +52,15 @@ More data of the applicant shall be visble an extra dialog @switch (context2.Item?.State) { case TableRegistrationRecord.RegistrationStateEnum.Pending: - Approve - Reject + Approve + Reject @*Show the delete button only for admins*@ - + - Delete + Delete break; @@ -72,7 +76,8 @@ More data of the applicant shall be visble an extra dialog } - More... + More... @@ -80,7 +85,7 @@ More data of the applicant shall be visble an extra dialog - + @@ -109,14 +114,14 @@ More data of the applicant shall be visble an extra dialog _dataGrid?.SetSortAsync(nameof(TableRegistrationRecord.State), SortDirection.Ascending, x => x.State); } } - + private async Task DeleteRegistration(TableRegistrationRecord registrationRecord) { DialogParameters dialog = new() - { - { x => x.ContentText, $"Are you sure you want to delete this application?" }, - { x => x.ActionButtonText, "Confirm" } - }; +{ +{ x => x.ContentText, $"Are you sure you want to delete this application?" }, +{ x => x.ActionButtonText, "Confirm" } +}; var options = new DialogOptions() { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall }; IDialogReference dialogRef = await DialogService.ShowAsync("Confirm", dialog, options); DialogResult result = await dialogRef.Result; @@ -138,17 +143,18 @@ More data of the applicant shall be visble an extra dialog private async void TryChangeRegistrationStatus(TableRegistrationRecord registrationRecord, bool reject) { DialogParameters dialog = new() - { - { x => x.ContentText, $"Are you sure you want to {(reject ? "reject" : "approve")} this application?" }, - { x => x.ActionButtonText, "Confirm" } - }; +{ +{ x => x.ContentText, $"Are you sure you want to {(reject ? "reject" : "approve")} this application?" }, +{ x => x.ActionButtonText, "Confirm" } +}; var options = new DialogOptions() { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall }; IDialogReference dialogRef = await DialogService.ShowAsync("Confirm", dialog, options); DialogResult result = await dialogRef.Result; if (!result.Canceled) { - await TableRegService.PutTableRegistrationStatusAsync(registrationRecord, reject ? TableRegistrationRecord.RegistrationStateEnum.Rejected : TableRegistrationRecord.RegistrationStateEnum.Accepted); + await TableRegService.PutTableRegistrationStatusAsync(registrationRecord, reject ? + TableRegistrationRecord.RegistrationStateEnum.Rejected : TableRegistrationRecord.RegistrationStateEnum.Accepted); _items = await GetRegistrationsAsync(); StateHasChanged(); Snackbar.Add($"Application was {(reject ? "rejected" : "approved")}.", Severity.Success); @@ -162,9 +168,9 @@ More data of the applicant shall be visble an extra dialog private async Task OpenMoreDialog(TableRegistrationRecord contextItem) { var parameters = new DialogParameters() - { - { x => x.Record, contextItem } - }; +{ +{ x => x.Record, contextItem } +}; var options = new DialogOptions { MaxWidth = MaxWidth.Large, FullWidth = true, CloseButton = true }; @@ -183,10 +189,11 @@ More data of the applicant shall be visble an extra dialog /// /// private IEnumerable Filter(IEnumerable entries) => - string.IsNullOrEmpty(_search) ? entries : entries.Where(x => x.DisplayName.Contains(_search, StringComparison.OrdinalIgnoreCase) - || x.OwnerUsername.Contains(_search, StringComparison.OrdinalIgnoreCase) - || x.Location.Contains(_search, StringComparison.OrdinalIgnoreCase) - || x.ShortDescription.Contains(_search, StringComparison.OrdinalIgnoreCase)); + string.IsNullOrEmpty(_search) ? entries : entries.Where(x => x.DisplayName.Contains(_search, + StringComparison.OrdinalIgnoreCase) + || x.OwnerUsername.Contains(_search, StringComparison.OrdinalIgnoreCase) + || x.Location.Contains(_search, StringComparison.OrdinalIgnoreCase) + || x.ShortDescription.Contains(_search, StringComparison.OrdinalIgnoreCase)); /// @@ -200,9 +207,9 @@ More data of the applicant shall be visble an extra dialog // Show pending applications fist. // Sorting may be changed by the user in the UI. registrations = registrations - .Select(x => x) - .OrderBy(x => x.State) - .ToList(); + .Select(x => x) + .OrderBy(x => x.State) + .ToList(); registrations = Filter(registrations); diff --git a/src/Eurofurence.App.Backoffice/Program.cs b/src/Eurofurence.App.Backoffice/Program.cs index e92613b1..d226e1c6 100644 --- a/src/Eurofurence.App.Backoffice/Program.cs +++ b/src/Eurofurence.App.Backoffice/Program.cs @@ -38,7 +38,13 @@ builder.Services.AddAuthorizationCore(config => { config.AddPolicy("RequireKnowledgeBaseEditor", policy => - policy.RequireRole("KnowledgeBaseEditor") + policy.RequireRole(["KnowledgeBaseEditor", "Admin"]) + ); + config.AddPolicy("RequireArtistAlleyModerator", policy => + policy.RequireRole(["ArtistAlleyModerator", "ArtistAlleyAdmin", "Admin"]) + ); + config.AddPolicy("RequireArtistAlleyAdmin", policy => + policy.RequireRole(["ArtistAlleyAdmin", "Admin"]) ); } ); diff --git a/src/Eurofurence.App.Server.Web/Controllers/ArtistsAlleyController.cs b/src/Eurofurence.App.Server.Web/Controllers/ArtistsAlleyController.cs index 0ba54c00..3d15ef19 100644 --- a/src/Eurofurence.App.Server.Web/Controllers/ArtistsAlleyController.cs +++ b/src/Eurofurence.App.Server.Web/Controllers/ArtistsAlleyController.cs @@ -27,8 +27,8 @@ public ArtistsAlleyController(ITableRegistrationService tableRegistrationService } [HttpPut("{id}/:status")] - [Authorize(Roles = "Admin, ArtistAlleyAdmin")] - public async Task PutTableRegistrationStatusAsync([EnsureNotNull] [FromRoute] Guid id, + [Authorize(Roles = "Admin, ArtistAlleyAdmin, ArtistAlleyModerator")] + public async Task PutTableRegistrationStatusAsync([EnsureNotNull][FromRoute] Guid id, [FromBody] TableRegistrationRecord.RegistrationStateEnum state) { TableRegistrationRecord record = diff --git a/src/Eurofurence.App.Server.Web/Identity/AuthorizationOptions.cs b/src/Eurofurence.App.Server.Web/Identity/AuthorizationOptions.cs index eb13f755..126d991b 100644 --- a/src/Eurofurence.App.Server.Web/Identity/AuthorizationOptions.cs +++ b/src/Eurofurence.App.Server.Web/Identity/AuthorizationOptions.cs @@ -19,9 +19,10 @@ public class AuthorizationOptions /// /// Artist alley moderators may approve or reject table applications from attendees. - /// /// public HashSet ArtistAlleyModerator { get; set; } = new(); + public HashSet ArtistAlleyAdmin { get; set; } = new(); + public HashSet PrivateMessageSender { get; set; } = new(); } \ No newline at end of file diff --git a/src/Eurofurence.App.Server.Web/Identity/RolesClaimsTransformation.cs b/src/Eurofurence.App.Server.Web/Identity/RolesClaimsTransformation.cs index 9ce3cf15..bcfb59ea 100644 --- a/src/Eurofurence.App.Server.Web/Identity/RolesClaimsTransformation.cs +++ b/src/Eurofurence.App.Server.Web/Identity/RolesClaimsTransformation.cs @@ -86,6 +86,11 @@ public async Task TransformAsync(ClaimsPrincipal principal) roles.Add("AttendeeCheckedIn"); } + if (authorizationOptions.Value.ArtistAlleyAdmin.Contains(claim.Value)) + { + roles.Add("ArtistAlleyAdmin"); + } + if (authorizationOptions.Value.ArtistAlleyModerator.Contains(claim.Value)) { roles.Add("ArtistAlleyModerator"); From 827aa18b3b534eddedabe68882ae95cb9d03ab3b Mon Sep 17 00:00:00 2001 From: Fenrikur <3359222+Fenrikur@users.noreply.github.com> Date: Sun, 25 Aug 2024 20:37:16 +0200 Subject: [PATCH 2/6] feat(artistalley): restrict registration to checked-in role --- .../Controllers/ArtistsAlleyController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Eurofurence.App.Server.Web/Controllers/ArtistsAlleyController.cs b/src/Eurofurence.App.Server.Web/Controllers/ArtistsAlleyController.cs index 3d15ef19..fddfb9ee 100644 --- a/src/Eurofurence.App.Server.Web/Controllers/ArtistsAlleyController.cs +++ b/src/Eurofurence.App.Server.Web/Controllers/ArtistsAlleyController.cs @@ -79,7 +79,7 @@ [EnsureNotNull][FromRoute] Guid id return (await _tableRegistrationService.FindOneAsync(id)).Transient404(HttpContext); } - [Authorize(Roles = "Attendee")] + [Authorize(Roles = "AttendeeCheckedIn")] [HttpPost("TableRegistrationRequest")] public async Task PostTableRegistrationRequestAsync([EnsureNotNull][FromForm] TableRegistrationRequest request, IFormFile requestImageFile) { @@ -104,7 +104,7 @@ public async Task PostTableRegistrationRequestAsync([EnsureNotNull return NoContent(); } - [Authorize(Roles = "Attendee")] + [Authorize(Roles = "AttendeeCheckedIn")] [HttpGet("TableRegistration/:my-latest")] public async Task GetMyLatestTableRegistrationRequestAsync() { From 5ee1b7f41af9ae5c530d3d627c2ee160fd107df1 Mon Sep 17 00:00:00 2001 From: Fenrikur <3359222+Fenrikur@users.noreply.github.com> Date: Sun, 25 Aug 2024 21:03:27 +0200 Subject: [PATCH 3/6] feat(artistalley): delete pending registration on resubmission --- .../ArtistsAlley/TableRegistrationService.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Eurofurence.App.Server.Services/ArtistsAlley/TableRegistrationService.cs b/src/Eurofurence.App.Server.Services/ArtistsAlley/TableRegistrationService.cs index 89c2b71b..81b12b14 100644 --- a/src/Eurofurence.App.Server.Services/ArtistsAlley/TableRegistrationService.cs +++ b/src/Eurofurence.App.Server.Services/ArtistsAlley/TableRegistrationService.cs @@ -85,9 +85,8 @@ public async Task RegisterTableAsync(ClaimsPrincipal user, TableRegistrationRequ foreach (var registration in activeRegistrations) { - var stateChange = registration.ChangeState(TableRegistrationRecord.RegistrationStateEnum.Rejected, subject); - _appDbContext.StateChangeRecord.Add(stateChange); - registration.Touch(); + if (registration.ImageId is { } imageId) await _imageService.DeleteOneAsync(imageId); + await DeleteOneAsync(registration.Id); } var record = new TableRegistrationRecord() @@ -118,7 +117,7 @@ public async Task ApproveByIdAsync(Guid id, string operatorUid) { var record = await _appDbContext.TableRegistrations.FirstOrDefaultAsync(a => a.Id == id && a.State == TableRegistrationRecord.RegistrationStateEnum.Pending); - var stateChange =record.ChangeState(TableRegistrationRecord.RegistrationStateEnum.Accepted, operatorUid); + var stateChange = record.ChangeState(TableRegistrationRecord.RegistrationStateEnum.Accepted, operatorUid); _appDbContext.StateChangeRecord.Add(stateChange); record.Touch(); From d0d5c3c17a219e6337634ba341456ededd8dc640 Mon Sep 17 00:00:00 2001 From: Fenrikur <3359222+Fenrikur@users.noreply.github.com> Date: Sun, 25 Aug 2024 22:20:08 +0200 Subject: [PATCH 4/6] chore(backoffice): button and table styling for artist alley --- .../ArtistAlleyApplicationDialog.razor | 8 ++-- .../Pages/ArtistAlleyModeration.razor | 39 +++++++++---------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/Eurofurence.App.Backoffice/Components/ArtistAlleyApplicationDialog.razor b/src/Eurofurence.App.Backoffice/Components/ArtistAlleyApplicationDialog.razor index af9e5a71..11bda6e2 100644 --- a/src/Eurofurence.App.Backoffice/Components/ArtistAlleyApplicationDialog.razor +++ b/src/Eurofurence.App.Backoffice/Components/ArtistAlleyApplicationDialog.razor @@ -20,7 +20,7 @@ } - + @@ -31,14 +31,14 @@ { case TableRegistrationRecord.RegistrationStateEnum.Pending: Pending - Approve - Reject @*Show the delete button only for admins*@ - + Delete diff --git a/src/Eurofurence.App.Backoffice/Pages/ArtistAlleyModeration.razor b/src/Eurofurence.App.Backoffice/Pages/ArtistAlleyModeration.razor index a8c97e87..cc3c3f88 100644 --- a/src/Eurofurence.App.Backoffice/Pages/ArtistAlleyModeration.razor +++ b/src/Eurofurence.App.Backoffice/Pages/ArtistAlleyModeration.razor @@ -27,7 +27,7 @@ More data of the applicant shall be visble an extra dialog - + @if (context.Item.Image != null && !string.IsNullOrEmpty(context.Item.Image.Url)) { @@ -41,28 +41,29 @@ More data of the applicant shall be visble an extra dialog - - + - + - - + + @switch (context2.Item?.State) { case TableRegistrationRecord.RegistrationStateEnum.Pending: - Approve - Reject - @*Show the delete button only for admins*@ - - - Delete - - + + Approve + Reject + @*Show the delete button only for admins*@ + + + Delete + + + break; case TableRegistrationRecord.RegistrationStateEnum.Accepted: Accepted @@ -74,10 +75,8 @@ More data of the applicant shall be visble an extra dialog Published break; } - - More... + OnClick="() => OpenMoreDialog(context2.Item)">Details From 72bcf3e0d92677f844518a3b1fcb73ff5ed48b8f Mon Sep 17 00:00:00 2001 From: Fenrikur <3359222+Fenrikur@users.noreply.github.com> Date: Sun, 25 Aug 2024 22:25:26 +0200 Subject: [PATCH 5/6] feat(backoffice): restrict images view to admins --- src/Eurofurence.App.Backoffice/Layout/NavMenu.razor | 2 ++ src/Eurofurence.App.Backoffice/Pages/Images.razor | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Eurofurence.App.Backoffice/Layout/NavMenu.razor b/src/Eurofurence.App.Backoffice/Layout/NavMenu.razor index fda256e0..0b9a7ca4 100644 --- a/src/Eurofurence.App.Backoffice/Layout/NavMenu.razor +++ b/src/Eurofurence.App.Backoffice/Layout/NavMenu.razor @@ -3,6 +3,8 @@ Knowledge Base + + Images diff --git a/src/Eurofurence.App.Backoffice/Pages/Images.razor b/src/Eurofurence.App.Backoffice/Pages/Images.razor index 5c15ba20..bbe445ea 100644 --- a/src/Eurofurence.App.Backoffice/Pages/Images.razor +++ b/src/Eurofurence.App.Backoffice/Pages/Images.razor @@ -1,5 +1,5 @@ @page "/images" -@attribute [Authorize(Policy = "RequireKnowledgeBaseEditor")] +@attribute [Authorize(Roles = "Admin")] @using Eurofurence.App.Backoffice.Services @using Microsoft.AspNetCore.Authorization @using Eurofurence.App.Domain.Model.Images @@ -177,10 +177,10 @@ private async Task DeleteImage(Guid id) { DialogParameters dialog = new() - { - { x => x.ContentText, $"Are you sure you want to delete this ímage?" }, - { x => x.ActionButtonText, "Confirm" } - }; +{ +{ x => x.ContentText, $"Are you sure you want to delete this ímage?" }, +{ x => x.ActionButtonText, "Confirm" } +}; var options = new DialogOptions() { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall }; IDialogReference dialogRef = await DialogService.ShowAsync("Confirm", dialog, options); DialogResult dialogResult = await dialogRef.Result; From f88d9651f25a2b9129fb948631c401040a790b3d Mon Sep 17 00:00:00 2001 From: Fenrikur <3359222+Fenrikur@users.noreply.github.com> Date: Sun, 25 Aug 2024 23:27:28 +0200 Subject: [PATCH 6/6] chore: fix indentation and warnings --- ef-app_backend-dotnet-core.code-workspace | 1 + .../ArtistAlleyApplicationDialog.razor | 28 +++++----- .../Pages/ArtistAlleyModeration.razor | 52 +++++++++---------- .../Pages/Images.razor | 20 +++---- 4 files changed, 50 insertions(+), 51 deletions(-) diff --git a/ef-app_backend-dotnet-core.code-workspace b/ef-app_backend-dotnet-core.code-workspace index 34205486..dab9b896 100644 --- a/ef-app_backend-dotnet-core.code-workspace +++ b/ef-app_backend-dotnet-core.code-workspace @@ -9,5 +9,6 @@ "editor.insertSpaces": true, "editor.indentSize": "tabSize", "editor.tabSize": 4, + "editor.formatOnSave": false, } } \ No newline at end of file diff --git a/src/Eurofurence.App.Backoffice/Components/ArtistAlleyApplicationDialog.razor b/src/Eurofurence.App.Backoffice/Components/ArtistAlleyApplicationDialog.razor index 11bda6e2..4e4a1167 100644 --- a/src/Eurofurence.App.Backoffice/Components/ArtistAlleyApplicationDialog.razor +++ b/src/Eurofurence.App.Backoffice/Components/ArtistAlleyApplicationDialog.razor @@ -61,21 +61,21 @@ @code { - [Parameter] public TableRegistrationRecord Record { get; set; } + [Parameter] public TableRegistrationRecord? Record { get; set; } private async Task DeleteRegistration() { DialogParameters dialog = new() -{ -{ x => x.ContentText, $"Are you sure you want to delete this application?" }, -{ x => x.ActionButtonText, "Confirm" } -}; + { + { x => x.ContentText, $"Are you sure you want to delete this application?" }, + { x => x.ActionButtonText, "Confirm" } + }; var options = new DialogOptions() { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall }; IDialogReference dialogRef = await DialogService.ShowAsync("Confirm", dialog, options); - DialogResult result = await dialogRef.Result; + DialogResult? result = await dialogRef.Result; - if (!result.Canceled) + if (result is { Canceled: false } && Record != null) { await TableRegService.DeleteTableRegistrationAsync(Record); Snackbar.Add("Application Deleted", Severity.Success); @@ -90,18 +90,18 @@ private async void TryChangeRegistrationStatus(TableRegistrationRecord registrationRecord, bool reject) { DialogParameters dialog = new() -{ -{ x => x.ContentText, $"Are you sure you want to {(reject ? "reject" : "approve")} this application?" }, -{ x => x.ActionButtonText, "Confirm" } -}; + { + { x => x.ContentText, $"Are you sure you want to {(reject ? "reject" : "approve")} this application?" }, + { x => x.ActionButtonText, "Confirm" } + }; var options = new DialogOptions() { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall }; IDialogReference dialogRef = await DialogService.ShowAsync("Confirm", dialog, options); - DialogResult result = await dialogRef.Result; + DialogResult? result = await dialogRef.Result; - if (!result.Canceled) + if (result is { Canceled: false } && Record != null) { var state = reject ? TableRegistrationRecord.RegistrationStateEnum.Rejected : - TableRegistrationRecord.RegistrationStateEnum.Accepted; + TableRegistrationRecord.RegistrationStateEnum.Accepted; await TableRegService.PutTableRegistrationStatusAsync(registrationRecord, state); Snackbar.Add($"Application was {(reject ? "rejected" : "approved")}."); diff --git a/src/Eurofurence.App.Backoffice/Pages/ArtistAlleyModeration.razor b/src/Eurofurence.App.Backoffice/Pages/ArtistAlleyModeration.razor index cc3c3f88..e94f1d63 100644 --- a/src/Eurofurence.App.Backoffice/Pages/ArtistAlleyModeration.razor +++ b/src/Eurofurence.App.Backoffice/Pages/ArtistAlleyModeration.razor @@ -17,7 +17,7 @@ + Adornment="Adornment.End" AdornmentIcon="@Icons.Material.Filled.Search" AdornmentColor="Color.Secondary" /> @* Table showing the basic informations for each application. @@ -33,7 +33,7 @@ More data of the applicant shall be visble an extra dialog { + Src="@context.Item.Image.Url" /> } @@ -117,15 +117,15 @@ More data of the applicant shall be visble an extra dialog private async Task DeleteRegistration(TableRegistrationRecord registrationRecord) { DialogParameters dialog = new() -{ -{ x => x.ContentText, $"Are you sure you want to delete this application?" }, -{ x => x.ActionButtonText, "Confirm" } -}; + { + { x => x.ContentText, $"Are you sure you want to delete this application?" }, + { x => x.ActionButtonText, "Confirm" } + }; var options = new DialogOptions() { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall }; IDialogReference dialogRef = await DialogService.ShowAsync("Confirm", dialog, options); - DialogResult result = await dialogRef.Result; + DialogResult? result = await dialogRef.Result; - if (!result.Canceled) + if (result is { Canceled: false }) { await TableRegService.DeleteTableRegistrationAsync(registrationRecord); _items = await GetRegistrationsAsync(); @@ -142,18 +142,18 @@ More data of the applicant shall be visble an extra dialog private async void TryChangeRegistrationStatus(TableRegistrationRecord registrationRecord, bool reject) { DialogParameters dialog = new() -{ -{ x => x.ContentText, $"Are you sure you want to {(reject ? "reject" : "approve")} this application?" }, -{ x => x.ActionButtonText, "Confirm" } -}; + { + { x => x.ContentText, $"Are you sure you want to {(reject ? "reject" : "approve")} this application?" }, + { x => x.ActionButtonText, "Confirm" } + }; var options = new DialogOptions() { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall }; IDialogReference dialogRef = await DialogService.ShowAsync("Confirm", dialog, options); - DialogResult result = await dialogRef.Result; + DialogResult? result = await dialogRef.Result; - if (!result.Canceled) + if (result is { Canceled: false }) { await TableRegService.PutTableRegistrationStatusAsync(registrationRecord, reject ? - TableRegistrationRecord.RegistrationStateEnum.Rejected : TableRegistrationRecord.RegistrationStateEnum.Accepted); + TableRegistrationRecord.RegistrationStateEnum.Rejected : TableRegistrationRecord.RegistrationStateEnum.Accepted); _items = await GetRegistrationsAsync(); StateHasChanged(); Snackbar.Add($"Application was {(reject ? "rejected" : "approved")}.", Severity.Success); @@ -166,10 +166,9 @@ More data of the applicant shall be visble an extra dialog /// private async Task OpenMoreDialog(TableRegistrationRecord contextItem) { - var parameters = new DialogParameters() -{ -{ x => x.Record, contextItem } -}; + var parameters = new DialogParameters() { + { x => x.Record, contextItem } + }; var options = new DialogOptions { MaxWidth = MaxWidth.Large, FullWidth = true, CloseButton = true }; @@ -188,11 +187,10 @@ More data of the applicant shall be visble an extra dialog /// /// private IEnumerable Filter(IEnumerable entries) => - string.IsNullOrEmpty(_search) ? entries : entries.Where(x => x.DisplayName.Contains(_search, - StringComparison.OrdinalIgnoreCase) - || x.OwnerUsername.Contains(_search, StringComparison.OrdinalIgnoreCase) - || x.Location.Contains(_search, StringComparison.OrdinalIgnoreCase) - || x.ShortDescription.Contains(_search, StringComparison.OrdinalIgnoreCase)); + string.IsNullOrEmpty(_search) ? entries : entries.Where(x => x.DisplayName.Contains(_search, StringComparison.OrdinalIgnoreCase) + || x.OwnerUsername.Contains(_search, StringComparison.OrdinalIgnoreCase) + || x.Location.Contains(_search, StringComparison.OrdinalIgnoreCase) + || x.ShortDescription.Contains(_search, StringComparison.OrdinalIgnoreCase)); /// @@ -206,9 +204,9 @@ More data of the applicant shall be visble an extra dialog // Show pending applications fist. // Sorting may be changed by the user in the UI. registrations = registrations - .Select(x => x) - .OrderBy(x => x.State) - .ToList(); + .Select(x => x) + .OrderBy(x => x.State) + .ToList(); registrations = Filter(registrations); diff --git a/src/Eurofurence.App.Backoffice/Pages/Images.razor b/src/Eurofurence.App.Backoffice/Pages/Images.razor index bbe445ea..831c451b 100644 --- a/src/Eurofurence.App.Backoffice/Pages/Images.razor +++ b/src/Eurofurence.App.Backoffice/Pages/Images.razor @@ -141,10 +141,10 @@ searchString) { return string.IsNullOrEmpty(searchString) - ? entries - : entries.Where(entry => - entry.InternalReference.ToLower().Contains(searchString.ToLower()) - || entry.Id.ToString().ToLower().Contains(searchString.ToLower())); + ? entries + : entries.Where(entry => + entry.InternalReference.ToLower().Contains(searchString.ToLower()) + || entry.Id.ToString().ToLower().Contains(searchString.ToLower())); } private async Task AddImage() @@ -177,15 +177,15 @@ private async Task DeleteImage(Guid id) { DialogParameters dialog = new() -{ -{ x => x.ContentText, $"Are you sure you want to delete this ímage?" }, -{ x => x.ActionButtonText, "Confirm" } -}; + { + { x => x.ContentText, $"Are you sure you want to delete this ímage?" }, + { x => x.ActionButtonText, "Confirm" } + }; var options = new DialogOptions() { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall }; IDialogReference dialogRef = await DialogService.ShowAsync("Confirm", dialog, options); - DialogResult dialogResult = await dialogRef.Result; + DialogResult? dialogResult = await dialogRef.Result; - if (!dialogResult.Canceled) + if (dialogResult is { Canceled: false }) { var result = await ImageService.DeleteImageAsync(id); if (result)