From 7208f1e86db5f7eba296c429bde7f6821a00d5f3 Mon Sep 17 00:00:00 2001 From: Andre Beging Date: Tue, 31 May 2022 15:08:55 +0200 Subject: [PATCH] Fixed a bunch of warnings --- .../Entity/Prospect.cs | 2 +- FoodsharingSiegen.Contracts/Helper/Cryptor.cs | 2 +- FoodsharingSiegen.Server/Auth/AuthService.cs | 7 +- .../Auth/TokenAuthStateProvider.cs | 10 +- .../BaseClasses/FsBase.cs | 15 ++- .../Controls/InteractionRow.razor | 45 +-------- .../Controls/InteractionRow.razor.cs | 99 +++++++++++++++++++ .../Controls/ProspectContainer.razor | 8 +- FoodsharingSiegen.Server/Data/AuditHelper.cs | 17 +++- .../Data/Service/AuditService.cs | 2 + .../Data/Service/ProspectService.cs | 12 +-- .../Data/Service/UserService.cs | 10 +- .../Dialogs/AddInteractionModal.razor.cs | 4 +- .../Dialogs/AddProspectModal.razor | 9 +- .../Dialogs/SetPasswordModal.razor | 14 +-- FoodsharingSiegen.Server/Pages/Login.razor | 4 - FoodsharingSiegen.Server/Pages/Login.razor.cs | 45 ++++----- .../Pages/Prospects.razor | 4 +- .../Pages/Prospects.razor.cs | 14 ++- FoodsharingSiegen.Server/Pages/Users.razor | 4 +- FoodsharingSiegen.Server/Pages/Users.razor.cs | 15 +-- 21 files changed, 202 insertions(+), 140 deletions(-) create mode 100644 FoodsharingSiegen.Server/Controls/InteractionRow.razor.cs diff --git a/FoodsharingSiegen.Contracts/Entity/Prospect.cs b/FoodsharingSiegen.Contracts/Entity/Prospect.cs index 2f700b1..8f42443 100644 --- a/FoodsharingSiegen.Contracts/Entity/Prospect.cs +++ b/FoodsharingSiegen.Contracts/Entity/Prospect.cs @@ -14,7 +14,7 @@ namespace FoodsharingSiegen.Contracts.Entity /// /// Gets the value of the complete (ab) /// - [NotMapped] public bool Complete => Interactions?.Any(x => x.Type == InteractionType.Complete) == true; + [NotMapped] public bool Complete => Interactions.Any(x => x.Type == InteractionType.Complete); /// /// Gets or sets the value of the created (ab) diff --git a/FoodsharingSiegen.Contracts/Helper/Cryptor.cs b/FoodsharingSiegen.Contracts/Helper/Cryptor.cs index 7023e2c..12f878e 100644 --- a/FoodsharingSiegen.Contracts/Helper/Cryptor.cs +++ b/FoodsharingSiegen.Contracts/Helper/Cryptor.cs @@ -38,7 +38,7 @@ namespace FoodsharingSiegen.Contracts.Helper return true; } - catch (Exception e) + catch (Exception) { return false; } diff --git a/FoodsharingSiegen.Server/Auth/AuthService.cs b/FoodsharingSiegen.Server/Auth/AuthService.cs index 223f62d..6ebc4c9 100644 --- a/FoodsharingSiegen.Server/Auth/AuthService.cs +++ b/FoodsharingSiegen.Server/Auth/AuthService.cs @@ -2,7 +2,6 @@ using FoodsharingSiegen.Contracts; using FoodsharingSiegen.Contracts.Entity; using FoodsharingSiegen.Contracts.Helper; using FoodsharingSiegen.Server.Data; -using FoodsharingSiegen.Server.Data.Service; using FoodsharingSiegen.Server.Service; using FoodsharingSiegen.Shared.Helper; using Microsoft.AspNetCore.Components.Authorization; @@ -100,7 +99,7 @@ namespace FoodsharingSiegen.Server.Auth { #region Ensure Admin - var existingTroogS = await Context.Users.AnyAsync(x => x.Mail == "fs@beging.de"); + var existingTroogS = await Context.Users!.AnyAsync(x => x.Mail == "fs@beging.de"); if (!existingTroogS) { var troogs = new User @@ -113,7 +112,7 @@ namespace FoodsharingSiegen.Server.Auth EncryptedPassword = "qSIxTZo7J8M=" }; - await Context.Users.AddAsync(troogs); + await Context.Users!.AddAsync(troogs); await Context.SaveChangesAsync(); } @@ -121,7 +120,7 @@ namespace FoodsharingSiegen.Server.Auth var encryptedPassword = Cryptor.Encrypt(password); - _user = await Context.Users.FirstOrDefaultAsync(x => x.Mail.ToLower() == mailAddress.ToLower() && x.EncryptedPassword == encryptedPassword); + _user = await Context.Users!.FirstOrDefaultAsync(x => x.Mail.ToLower() == mailAddress.ToLower() && x.EncryptedPassword == encryptedPassword); if (_user != null) { diff --git a/FoodsharingSiegen.Server/Auth/TokenAuthStateProvider.cs b/FoodsharingSiegen.Server/Auth/TokenAuthStateProvider.cs index 42c9124..9767814 100644 --- a/FoodsharingSiegen.Server/Auth/TokenAuthStateProvider.cs +++ b/FoodsharingSiegen.Server/Auth/TokenAuthStateProvider.cs @@ -2,12 +2,12 @@ using System.Security.Claims; using FoodsharingSiegen.Contracts; using FoodsharingSiegen.Contracts.Entity; using FoodsharingSiegen.Server.Data; -using FoodsharingSiegen.Server.Data.Service; +using FoodsharingSiegen.Server.Service; using FoodsharingSiegen.Shared.Helper; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.EntityFrameworkCore; -namespace FoodsharingSiegen.Server.Service +namespace FoodsharingSiegen.Server.Auth { /// /// The token auth state provider class (a. beging, 02.04.2022) @@ -84,11 +84,13 @@ namespace FoodsharingSiegen.Server.Service /// /// The user /// A task containing an operation result of bool - public async Task> CheckForceLogout(User user) + public async Task> CheckForceLogout(User? user) { try { - var anyR = await Context.Users.AnyAsync(x => x.Id == user.Id && x.ForceLogout); + if (user == null) return new OperationResult(new Exception()); + + var anyR = await Context.Users!.AnyAsync(x => x.Id == user.Id && x.ForceLogout); return new OperationResult(anyR); } catch (Exception e) diff --git a/FoodsharingSiegen.Server/BaseClasses/FsBase.cs b/FoodsharingSiegen.Server/BaseClasses/FsBase.cs index 7e96e17..14f01ba 100644 --- a/FoodsharingSiegen.Server/BaseClasses/FsBase.cs +++ b/FoodsharingSiegen.Server/BaseClasses/FsBase.cs @@ -1,7 +1,6 @@ using Blazorise; using FoodsharingSiegen.Contracts.Entity; using FoodsharingSiegen.Server.Auth; -using FoodsharingSiegen.Server.Data; using FoodsharingSiegen.Server.Data.Service; using Microsoft.AspNetCore.Components; @@ -20,7 +19,7 @@ namespace FoodsharingSiegen.Server.BaseClasses /// protected override async Task OnInitializedAsync() { - await AuthService!.Initialize(); + await AuthService.Initialize(); await base.OnInitializedAsync(); } @@ -31,27 +30,27 @@ namespace FoodsharingSiegen.Server.BaseClasses /// /// Gets or sets the value of the auth service (ab) /// - [Inject] private AuthService? AuthService { get; set; } + [Inject] protected AuthService AuthService { get; set; } = null!; /// /// Gets or sets the value of the audit service (ab) /// - [Inject] private AuditService? AuditService { get; set; } + [Inject] private AuditService AuditService { get; set; } = null!; /// /// Gets or sets the value of the notification (ab) /// - [Inject] protected INotificationService? Notification { get; set; } + [Inject] protected INotificationService Notification { get; set; } = null!; /// /// Gets or sets the value of the message (ab) /// - [Inject] protected IMessageService? Message { get; set; } - + [Inject] protected IMessageService Message { get; set; } = null!; + /// /// Gets or sets the value of the navigation manager (ab) /// - [Inject] protected NavigationManager? NavigationManager { get; set; } + [Inject] protected NavigationManager NavigationManager { get; set; } = null!; #endregion diff --git a/FoodsharingSiegen.Server/Controls/InteractionRow.razor b/FoodsharingSiegen.Server/Controls/InteractionRow.razor index 1eed3c0..e709c6a 100644 --- a/FoodsharingSiegen.Server/Controls/InteractionRow.razor +++ b/FoodsharingSiegen.Server/Controls/InteractionRow.razor @@ -1,46 +1,5 @@ @using FoodsharingSiegen.Contracts.Entity -@code { - - [Parameter] - public Prospect Prospect { get; set; } - - [Parameter] - public InteractionType Type { get; set; } - - [Parameter] - public EventCallback AddClick { get; set; } - - [Parameter] - public EventCallback RemoveClick { get; set; } - - [Parameter] - public string Caption { get; set; } - - [Parameter] - public string ButtonText { get; set; } - - [Parameter] - public string IconClass { get; set; } - - [Parameter] - public bool Multiple { get; set; } - - [Parameter] - public int Minimum { get; set; } = 1; - - [Parameter] - public bool AllowAddInteraction { get; set; } - - private List Interactions => Prospect?.Interactions?.Where(x => x.Type == Type).ToList() ?? new List(); - - private bool Done => Interactions.Count >= Minimum; - - private bool NotNeeded => Interactions.Any(x => x.NotNeeded); - - private bool Alert => Interactions.Any(x => x.Alert); -} - @{ var rowClass = ""; if (Done) rowClass += " done"; @@ -65,7 +24,7 @@ (@interaction.Info) } - @if ((!Prospect.Complete || interaction.Type == InteractionType.Complete) && AllowAddInteraction) + @if ((Prospect is not {Complete: true } || interaction.Type == InteractionType.Complete) && AllowAddInteraction) {   } @@ -74,7 +33,7 @@ } } - @if (!Prospect.Complete && (Interactions.Count == 0 || Multiple) && AllowAddInteraction) + @if (Prospect is not {Complete: true } && (Interactions.Count == 0 || Multiple) && AllowAddInteraction) { if (Multiple) ButtonText = "+"; diff --git a/FoodsharingSiegen.Server/Controls/InteractionRow.razor.cs b/FoodsharingSiegen.Server/Controls/InteractionRow.razor.cs new file mode 100644 index 0000000..d12aa5f --- /dev/null +++ b/FoodsharingSiegen.Server/Controls/InteractionRow.razor.cs @@ -0,0 +1,99 @@ +using FoodsharingSiegen.Contracts.Entity; +using Microsoft.AspNetCore.Components; + +namespace FoodsharingSiegen.Server.Controls +{ + /// + /// The interaction row class (a. beging, 31.05.2022) + /// + public partial class InteractionRow + { + #region Parameters + + /// + /// Gets or sets the value of the add click (ab) + /// + [Parameter] + public EventCallback AddClick { get; set; } + + /// + /// Gets or sets the value of the allow add interaction (ab) + /// + [Parameter] + public bool AllowAddInteraction { get; set; } + + /// + /// Gets or sets the value of the button text (ab) + /// + [Parameter] + public string? ButtonText { get; set; } + + /// + /// Gets or sets the value of the caption (ab) + /// + [Parameter] + public string? Caption { get; set; } + + /// + /// Gets or sets the value of the icon class (ab) + /// + [Parameter] + public string? IconClass { get; set; } + + /// + /// Gets or sets the value of the minimum (ab) + /// + [Parameter] + public int Minimum { get; set; } = 1; + + /// + /// Gets or sets the value of the multiple (ab) + /// + [Parameter] + public bool Multiple { get; set; } + + /// + /// Gets or sets the value of the prospect (ab) + /// + [Parameter] + public Prospect? Prospect { get; set; } + + /// + /// Gets or sets the value of the remove click (ab) + /// + [Parameter] + public EventCallback RemoveClick { get; set; } + + /// + /// Gets or sets the value of the type (ab) + /// + [Parameter] + public InteractionType Type { get; set; } + + #endregion + + #region Private Properties + + /// + /// Gets the value of the alert (ab) + /// + private bool Alert => Interactions.Any(x => x.Alert); + + /// + /// Gets the value of the done (ab) + /// + private bool Done => Interactions.Count >= Minimum; + + /// + /// Gets the value of the interactions (ab) + /// + private List Interactions => Prospect?.Interactions?.Where(x => x.Type == Type).ToList() ?? new List(); + + /// + /// Gets the value of the not needed (ab) + /// + private bool NotNeeded => Interactions.Any(x => x.NotNeeded); + + #endregion + } +} \ No newline at end of file diff --git a/FoodsharingSiegen.Server/Controls/ProspectContainer.razor b/FoodsharingSiegen.Server/Controls/ProspectContainer.razor index 0e60924..9d621ed 100644 --- a/FoodsharingSiegen.Server/Controls/ProspectContainer.razor +++ b/FoodsharingSiegen.Server/Controls/ProspectContainer.razor @@ -5,7 +5,7 @@ @{ var divClass = $"{CssClass} pc-main"; - if (Prospect.Complete) divClass += " complete"; + if (Prospect is {Complete: true }) divClass += " complete"; }
@@ -15,12 +15,12 @@ } - @Prospect.Name + @Prospect?.Name - Profil öffnen + Profil öffnen -
@Prospect.Memo
+
@Prospect?.Memo
+ /// The audit helper class (a. beging, 31.05.2022) + /// public static class AuditHelper { + #region Public Method CreateText + + /// + /// Creates the text using the specified audit (a. beging, 31.05.2022) + /// + /// The audit + /// The string public static string CreateText(Audit audit) { switch (audit.Type) @@ -28,13 +38,12 @@ namespace FoodsharingSiegen.Server.Data return $"hat dem Neuling {audit.Data1} folgendes hinzugefügt: {audit.Data2}"; case AuditType.RemoveInteraction: return $"hat eine Interaktion bei {audit.Data1} gelöscht."; - break; case AuditType.None: default: return $"{audit.Data1}, {audit.Data2}"; } - - return string.Empty; } + + #endregion } } \ No newline at end of file diff --git a/FoodsharingSiegen.Server/Data/Service/AuditService.cs b/FoodsharingSiegen.Server/Data/Service/AuditService.cs index cbeeaa5..5d438f7 100644 --- a/FoodsharingSiegen.Server/Data/Service/AuditService.cs +++ b/FoodsharingSiegen.Server/Data/Service/AuditService.cs @@ -72,6 +72,8 @@ namespace FoodsharingSiegen.Server.Data.Service { try { + await Task.CompletedTask; + var query = Context.Audits?.Include(x => x.User).OrderByDescending(x => x.Created).AsQueryable(); if (count > 0) diff --git a/FoodsharingSiegen.Server/Data/Service/ProspectService.cs b/FoodsharingSiegen.Server/Data/Service/ProspectService.cs index 387baab..cfbdb1f 100644 --- a/FoodsharingSiegen.Server/Data/Service/ProspectService.cs +++ b/FoodsharingSiegen.Server/Data/Service/ProspectService.cs @@ -11,7 +11,7 @@ namespace FoodsharingSiegen.Server.Data.Service /// public class ProspectService : ServiceBase { - public AuditService AuditService { get; } + private AuditService AuditService { get; } #region Setup/Teardown @@ -36,7 +36,7 @@ namespace FoodsharingSiegen.Server.Data.Service { try { - var targetProspect = await Context.Prospects.Include(x => x.Interactions).FirstOrDefaultAsync(x => x.Id == interaction.ProspectID); + var targetProspect = await Context.Prospects!.Include(x => x.Interactions).FirstOrDefaultAsync(x => x.Id == interaction.ProspectID); if (targetProspect == null) return new OperationResult(new Exception("Invalid prospect id")); interaction.ProspectID = Guid.Empty; @@ -78,7 +78,7 @@ namespace FoodsharingSiegen.Server.Data.Service prospect.Created = DateTime.UtcNow; prospect.Id = Guid.Empty; - await Context.Prospects.AddAsync(prospect); + await Context.Prospects!.AddAsync(prospect); var saveR = await Context.SaveChangesAsync(); if (saveR > 0) @@ -107,7 +107,7 @@ namespace FoodsharingSiegen.Server.Data.Service { try { - var prospects = await Context.Prospects.AsNoTracking().Include(x => x.Interactions.OrderBy(i => i.Date)).ThenInclude(x => x.User).OrderBy(x => x.Name).ToListAsync(); + var prospects = await Context.Prospects!.AsNoTracking().Include(x => x.Interactions.OrderBy(i => i.Date)).ThenInclude(x => x.User).OrderBy(x => x.Name).ToListAsync(); return new OperationResult>(prospects); } catch (Exception e) @@ -129,7 +129,7 @@ namespace FoodsharingSiegen.Server.Data.Service { try { - Context.Interactions.Remove(new Interaction { Id = interactionId }); + Context.Interactions!.Remove(new Interaction { Id = interactionId }); await Context.SaveChangesAsync(); await AuditService.Insert(AuditType.RemoveInteraction, "?"); @@ -155,7 +155,7 @@ namespace FoodsharingSiegen.Server.Data.Service { try { - var entityProspect = await Context.Prospects.FirstOrDefaultAsync(x => x.Id == prospect.Id); + var entityProspect = await Context.Prospects!.FirstOrDefaultAsync(x => x.Id == prospect.Id); if (entityProspect == null) return new OperationResult(new Exception("Prospect not found")); entityProspect.Memo = prospect.Memo; diff --git a/FoodsharingSiegen.Server/Data/Service/UserService.cs b/FoodsharingSiegen.Server/Data/Service/UserService.cs index 77e3939..3d1387b 100644 --- a/FoodsharingSiegen.Server/Data/Service/UserService.cs +++ b/FoodsharingSiegen.Server/Data/Service/UserService.cs @@ -33,7 +33,7 @@ namespace FoodsharingSiegen.Server.Data.Service { try { - if (await Context.Users.AnyAsync(x => x.Mail.ToLower().Equals(user.Mail.ToLower()))) + if (await Context.Users!.AnyAsync(x => x.Mail.ToLower().Equals(user.Mail.ToLower()))) return new OperationResult(new Exception("Diese E-Mail Adresse wird bereits verwendet")); user.Created = DateTime.UtcNow; @@ -41,7 +41,7 @@ namespace FoodsharingSiegen.Server.Data.Service if (string.IsNullOrWhiteSpace(user.Password)) user.Password = string.Empty; - await Context.Users.AddAsync(user); + await Context.Users!.AddAsync(user); var saveResult = await Context.SaveChangesAsync(); if (saveResult == 0) return new OperationResult(new Exception("Fehler bei der Registrierung")); @@ -70,7 +70,7 @@ namespace FoodsharingSiegen.Server.Data.Service { try { - var users = await Context.Users.AsNoTracking().ToListAsync(); + var users = await Context.Users!.AsNoTracking().ToListAsync(); return new OperationResult>(users); } catch (Exception e) @@ -92,7 +92,7 @@ namespace FoodsharingSiegen.Server.Data.Service { try { - var entityUser = await Context.Users.FirstOrDefaultAsync(x => x.Id == user.Id); + var entityUser = await Context.Users!.FirstOrDefaultAsync(x => x.Id == user.Id); if (entityUser == null) return new OperationResult(new Exception("User not found")); entityUser.Password = user.Password; @@ -121,7 +121,7 @@ namespace FoodsharingSiegen.Server.Data.Service { try { - var entityUser = await Context?.Users?.FirstOrDefaultAsync(x => x.Id == user.Id)!; + var entityUser = await Context.Users!.FirstOrDefaultAsync(x => x.Id == user.Id); if (entityUser == null) return new OperationResult(new Exception("User not found")); if (entityUser.Mail != user.Mail || diff --git a/FoodsharingSiegen.Server/Dialogs/AddInteractionModal.razor.cs b/FoodsharingSiegen.Server/Dialogs/AddInteractionModal.razor.cs index 1f73bfb..35a8265 100644 --- a/FoodsharingSiegen.Server/Dialogs/AddInteractionModal.razor.cs +++ b/FoodsharingSiegen.Server/Dialogs/AddInteractionModal.razor.cs @@ -18,8 +18,8 @@ namespace FoodsharingSiegen.Server.Dialogs public Guid SelectedUser { get; set; } - private string _header; - private string _infoName; + private string? _header; + private string? _infoName; private bool _showInfo; private bool _showAlert; private bool _showNotNeeded; diff --git a/FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor b/FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor index e52b17d..dc91ebb 100644 --- a/FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor +++ b/FoodsharingSiegen.Server/Dialogs/AddProspectModal.razor @@ -4,9 +4,9 @@ private Prospect Prospect { get; set; } = new(); - private string Header { get; set; } + private string? Header { get; set; } - private string SaveButtonText { get; set; } + private string? SaveButtonText { get; set; } private bool IsUpdateMode { get; set; } @@ -16,14 +16,15 @@ public async Task Show() { - Prospect = new(); + Prospect = new Prospect(); Header = "Neuling hinzufügen"; SaveButtonText = "Hinzufügen"; await ModalReference.Show(); } - public async Task Show(Prospect prospect) + public async Task Show(Prospect? prospect) { + if (prospect == null) return; Prospect = prospect; IsUpdateMode = true; Header = $"{Prospect.Name} bearbeiten"; diff --git a/FoodsharingSiegen.Server/Dialogs/SetPasswordModal.razor b/FoodsharingSiegen.Server/Dialogs/SetPasswordModal.razor index 82eb07f..57d34ce 100644 --- a/FoodsharingSiegen.Server/Dialogs/SetPasswordModal.razor +++ b/FoodsharingSiegen.Server/Dialogs/SetPasswordModal.razor @@ -7,8 +7,8 @@ private User User { get; set; } = new(); - private string Password { get; set; } - private string ConfirmPassword { get; set; } + private string? Password { get; set; } + private string? ConfirmPassword { get; set; } [Parameter] public EventCallback OnPasswortSet { get; set; } @@ -34,7 +34,7 @@ private async Task SaveClick(object arg) { - User.Password = Password; + User.Password = Password ?? string.Empty; await OnPasswortSet.InvokeAsync(User); await ModalReference.Hide(); } @@ -51,19 +51,19 @@ Passwort - + Passwort wiederholen - + - - + + \ No newline at end of file diff --git a/FoodsharingSiegen.Server/Pages/Login.razor b/FoodsharingSiegen.Server/Pages/Login.razor index 9c3e879..9c53822 100644 --- a/FoodsharingSiegen.Server/Pages/Login.razor +++ b/FoodsharingSiegen.Server/Pages/Login.razor @@ -1,13 +1,9 @@ @page "/login" -@using FoodsharingSiegen.Server.Auth @using FoodsharingSiegen.Shared.Helper @layout LoginLayout @inherits FoodsharingSiegen.Server.BaseClasses.FsBase -@inject AuthService AuthService -@inject NavigationManager NavigationManager -
FS Siegen
diff --git a/FoodsharingSiegen.Server/Pages/Login.razor.cs b/FoodsharingSiegen.Server/Pages/Login.razor.cs index 94b599e..b9ba74b 100644 --- a/FoodsharingSiegen.Server/Pages/Login.razor.cs +++ b/FoodsharingSiegen.Server/Pages/Login.razor.cs @@ -4,33 +4,32 @@ using Microsoft.AspNetCore.Components.Web; namespace FoodsharingSiegen.Server.Pages { /// - /// The login class (a. beging, 11.04.2022) + /// The login class (a. beging, 11.04.2022) /// public partial class Login { - #region Public Properties - - /// - /// Gets or sets the value of the is valid mail (ab) - /// - public ValidationStatus IsValidMail { get; set; } - - /// - /// Gets or sets the value of the is valid password (ab) - /// - public ValidationStatus IsValidPassword { get; set; } - - #endregion - #region Private Properties /// - /// Gets or sets the value of the mail-address (ab) + /// Gets or sets the value of the is valid mail (ab) + /// + private ValidationStatus IsValidMail { get; set; } + + /// + /// Gets or sets the value of the is valid password (ab) + /// + private ValidationStatus IsValidPassword { get; set; } + + /// + /// Gets or sets the value of the auth service (ab) + /// + /// + /// Gets or sets the value of the mail-address (ab) /// private string? MailAddress { get; set; } /// - /// Gets or sets the value of the password (ab) + /// Gets or sets the value of the password (ab) /// private string? Password { get; set; } @@ -39,7 +38,7 @@ namespace FoodsharingSiegen.Server.Pages #region Private Method PerformLogin /// - /// Performs the login (a. beging, 11.04.2022) + /// Performs the login (a. beging, 11.04.2022) /// private async Task PerformLogin() { @@ -51,16 +50,12 @@ namespace FoodsharingSiegen.Server.Pages Password = string.Empty; return; } - + var loginR = await AuthService.Login(MailAddress, Password); if (loginR.Success) - { NavigationManager.NavigateTo("/", true); - } else - { - await Notification?.Error(loginR.ErrorMessage)!; - } + await Notification.Error(loginR.ErrorMessage)!; } #endregion @@ -68,7 +63,7 @@ namespace FoodsharingSiegen.Server.Pages #region Private Method TextEdit_KeyUp /// - /// Texts the edit key up using the specified arg (a. beging, 11.04.2022) + /// Texts the edit key up using the specified arg (a. beging, 11.04.2022) /// /// The arg private async Task TextEdit_KeyUp(KeyboardEventArgs arg) diff --git a/FoodsharingSiegen.Server/Pages/Prospects.razor b/FoodsharingSiegen.Server/Pages/Prospects.razor index ff156f8..4470837 100644 --- a/FoodsharingSiegen.Server/Pages/Prospects.razor +++ b/FoodsharingSiegen.Server/Pages/Prospects.razor @@ -28,7 +28,7 @@

Aktuell:

- +
} @@ -43,7 +43,7 @@

Abgeschlossen:

- +
} diff --git a/FoodsharingSiegen.Server/Pages/Prospects.razor.cs b/FoodsharingSiegen.Server/Pages/Prospects.razor.cs index 1eef25b..842b58c 100644 --- a/FoodsharingSiegen.Server/Pages/Prospects.razor.cs +++ b/FoodsharingSiegen.Server/Pages/Prospects.razor.cs @@ -16,7 +16,7 @@ namespace FoodsharingSiegen.Server.Pages /// /// Gets or sets the value of the message service (ab) /// - [Inject] IMessageService MessageService { get; set; } + [Inject] private IMessageService MessageService { get; set; } = null!; /// /// Gets or sets the value of the prospect service (ab) @@ -35,22 +35,22 @@ namespace FoodsharingSiegen.Server.Pages /// /// Gets or sets the value of the interaction modal (ab) /// - public AddInteractionModal InteractionModal { get; set; } + private AddInteractionModal? InteractionModal { get; set; } /// /// Gets or sets the value of the prospect list (ab) /// - public List? ProspectList { get; set; } + private List? ProspectList { get; set; } /// /// Gets or sets the value of the prospect modal (ab) /// - public AddProspectModal ProspectModal { get; set; } = null!; + private AddProspectModal ProspectModal { get; set; } = null!; /// /// Gets or sets the value of the users (ab) /// - public List? Users { get; set; } + private List? Users { get; set; } #endregion @@ -63,9 +63,7 @@ namespace FoodsharingSiegen.Server.Pages protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) - { await LoadProspects(); - } await base.OnAfterRenderAsync(firstRender); } @@ -158,7 +156,7 @@ namespace FoodsharingSiegen.Server.Pages o.CancelButtonText = "Abbrechen"; o.ShowMessageIcon = false; }); - + if (confirm) { await ProspectService.RemoveInteraction(arg); diff --git a/FoodsharingSiegen.Server/Pages/Users.razor b/FoodsharingSiegen.Server/Pages/Users.razor index 0d2b397..191e686 100644 --- a/FoodsharingSiegen.Server/Pages/Users.razor +++ b/FoodsharingSiegen.Server/Pages/Users.razor @@ -27,7 +27,7 @@

Benutzerverwaltung Admin

- +
diff --git a/FoodsharingSiegen.Server/Pages/Users.razor.cs b/FoodsharingSiegen.Server/Pages/Users.razor.cs index 1c67231..7fe39ea 100644 --- a/FoodsharingSiegen.Server/Pages/Users.razor.cs +++ b/FoodsharingSiegen.Server/Pages/Users.razor.cs @@ -28,7 +28,7 @@ namespace FoodsharingSiegen.Server.Pages /// /// Gets or sets the value of the password modal (ab) /// - private SetPasswordModal PasswordModal { get; set; } + private SetPasswordModal? PasswordModal { get; set; } /// /// Gets or sets the value of the selected company texts (ab) @@ -43,7 +43,7 @@ namespace FoodsharingSiegen.Server.Pages /// /// Gets or sets the value of the user data grid (ab) /// - private DataGrid UserDataGrid { get; set; } + private DataGrid? UserDataGrid { get; set; } /// /// Gets the value of the user groups (ab) @@ -96,9 +96,9 @@ namespace FoodsharingSiegen.Server.Pages /// The user private async Task OnPasswordSet(User user) { - var setPasswordR = await UserService?.SetPassword(user)!; + var setPasswordR = await UserService.SetPassword(user); if(setPasswordR.Success) - await Notification?.Success("Passwort gespeichert")!; + await Notification.Success("Passwort gespeichert"); } #endregion @@ -113,7 +113,7 @@ namespace FoodsharingSiegen.Server.Pages { var addUserR = await UserService.AddUserAsync(arg.Item); if (!addUserR.Success) - await Notification?.Error($"Fehler beim Anlegen: {addUserR.ErrorMessage}")!; + await Notification.Error($"Fehler beim Anlegen: {addUserR.ErrorMessage}")!; else await LoadUsers(); } @@ -130,7 +130,10 @@ namespace FoodsharingSiegen.Server.Pages { if (arg.Item?.Id == null || arg.Item.Id.Equals(Guid.Empty) || arg.Values?.Any() != true) return; - var result = await UserService.Update(arg.Item); + var updateR = await UserService.Update(arg.Item); + if(!updateR.Success) + await Notification.Error($"Fehler beim Speichern: {updateR.ErrorMessage}")!; + } #endregion