Fixed a bunch of warnings

This commit is contained in:
Andre Beging
2022-05-31 15:08:55 +02:00
parent cd22c2f215
commit 7208f1e86d
21 changed files with 202 additions and 140 deletions

View File

@@ -14,7 +14,7 @@ namespace FoodsharingSiegen.Contracts.Entity
/// <summary>
/// Gets the value of the complete (ab)
/// </summary>
[NotMapped] public bool Complete => Interactions?.Any(x => x.Type == InteractionType.Complete) == true;
[NotMapped] public bool Complete => Interactions.Any(x => x.Type == InteractionType.Complete);
/// <summary>
/// Gets or sets the value of the created (ab)

View File

@@ -38,7 +38,7 @@ namespace FoodsharingSiegen.Contracts.Helper
return true;
}
catch (Exception e)
catch (Exception)
{
return false;
}

View File

@@ -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)
{

View File

@@ -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
{
/// <summary>
/// The token auth state provider class (a. beging, 02.04.2022)
@@ -84,11 +84,13 @@ namespace FoodsharingSiegen.Server.Service
/// </summary>
/// <param name="user">The user</param>
/// <returns>A task containing an operation result of bool</returns>
public async Task<OperationResult<bool>> CheckForceLogout(User user)
public async Task<OperationResult<bool>> CheckForceLogout(User? user)
{
try
{
var anyR = await Context.Users.AnyAsync(x => x.Id == user.Id && x.ForceLogout);
if (user == null) return new OperationResult<bool>(new Exception());
var anyR = await Context.Users!.AnyAsync(x => x.Id == user.Id && x.ForceLogout);
return new OperationResult<bool>(anyR);
}
catch (Exception e)

View File

@@ -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
/// </summary>
protected override async Task OnInitializedAsync()
{
await AuthService!.Initialize();
await AuthService.Initialize();
await base.OnInitializedAsync();
}
@@ -31,27 +30,27 @@ namespace FoodsharingSiegen.Server.BaseClasses
/// <summary>
/// Gets or sets the value of the auth service (ab)
/// </summary>
[Inject] private AuthService? AuthService { get; set; }
[Inject] protected AuthService AuthService { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the audit service (ab)
/// </summary>
[Inject] private AuditService? AuditService { get; set; }
[Inject] private AuditService AuditService { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the notification (ab)
/// </summary>
[Inject] protected INotificationService? Notification { get; set; }
[Inject] protected INotificationService Notification { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the message (ab)
/// </summary>
[Inject] protected IMessageService? Message { get; set; }
[Inject] protected IMessageService Message { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the navigation manager (ab)
/// </summary>
[Inject] protected NavigationManager? NavigationManager { get; set; }
[Inject] protected NavigationManager NavigationManager { get; set; } = null!;
#endregion

View File

@@ -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<Guid> 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<Interaction> Interactions => Prospect?.Interactions?.Where(x => x.Type == Type).ToList() ?? new List<Interaction>();
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 @@
<span>(<i>@interaction.Info</i>)</span>
}
@if ((!Prospect.Complete || interaction.Type == InteractionType.Complete) && AllowAddInteraction)
@if ((Prospect is not {Complete: true } || interaction.Type == InteractionType.Complete) && AllowAddInteraction)
{
<span>&nbsp;<a href=""><i class="fa-solid fa-square-xmark" @onclick="async () => await RemoveClick.InvokeAsync(interaction.Id)" @onclick:preventDefault></i></a></span>
}
@@ -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 = "+";
<Button Size="Size.Small" Clicked="AddClick">@ButtonText</Button>

View File

@@ -0,0 +1,99 @@
using FoodsharingSiegen.Contracts.Entity;
using Microsoft.AspNetCore.Components;
namespace FoodsharingSiegen.Server.Controls
{
/// <summary>
/// The interaction row class (a. beging, 31.05.2022)
/// </summary>
public partial class InteractionRow
{
#region Parameters
/// <summary>
/// Gets or sets the value of the add click (ab)
/// </summary>
[Parameter]
public EventCallback AddClick { get; set; }
/// <summary>
/// Gets or sets the value of the allow add interaction (ab)
/// </summary>
[Parameter]
public bool AllowAddInteraction { get; set; }
/// <summary>
/// Gets or sets the value of the button text (ab)
/// </summary>
[Parameter]
public string? ButtonText { get; set; }
/// <summary>
/// Gets or sets the value of the caption (ab)
/// </summary>
[Parameter]
public string? Caption { get; set; }
/// <summary>
/// Gets or sets the value of the icon class (ab)
/// </summary>
[Parameter]
public string? IconClass { get; set; }
/// <summary>
/// Gets or sets the value of the minimum (ab)
/// </summary>
[Parameter]
public int Minimum { get; set; } = 1;
/// <summary>
/// Gets or sets the value of the multiple (ab)
/// </summary>
[Parameter]
public bool Multiple { get; set; }
/// <summary>
/// Gets or sets the value of the prospect (ab)
/// </summary>
[Parameter]
public Prospect? Prospect { get; set; }
/// <summary>
/// Gets or sets the value of the remove click (ab)
/// </summary>
[Parameter]
public EventCallback<Guid> RemoveClick { get; set; }
/// <summary>
/// Gets or sets the value of the type (ab)
/// </summary>
[Parameter]
public InteractionType Type { get; set; }
#endregion
#region Private Properties
/// <summary>
/// Gets the value of the alert (ab)
/// </summary>
private bool Alert => Interactions.Any(x => x.Alert);
/// <summary>
/// Gets the value of the done (ab)
/// </summary>
private bool Done => Interactions.Count >= Minimum;
/// <summary>
/// Gets the value of the interactions (ab)
/// </summary>
private List<Interaction> Interactions => Prospect?.Interactions?.Where(x => x.Type == Type).ToList() ?? new List<Interaction>();
/// <summary>
/// Gets the value of the not needed (ab)
/// </summary>
private bool NotNeeded => Interactions.Any(x => x.NotNeeded);
#endregion
}
}

View File

@@ -5,7 +5,7 @@
@{
var divClass = $"{CssClass} pc-main";
if (Prospect.Complete) divClass += " complete";
if (Prospect is {Complete: true }) divClass += " complete";
}
<div class="@divClass">
@@ -15,12 +15,12 @@
<a href=""><i class="fa-solid fa-pen-to-square" @onclick="() => ProspectModal.Show(Prospect)" @onclick:preventDefault></i> </a>
}
@Prospect.Name
@Prospect?.Name
<small style="font-size: .9rem; opacity: .7;">
<a class="invert" href="@(CurrentUser.NetworkLink)/profile/@Prospect.FsId" target="_blank">Profil öffnen</a>
<a class="invert" href="@(CurrentUser.NetworkLink)/profile/@Prospect?.FsId" target="_blank">Profil öffnen</a>
</small>
</h5>
<div>@Prospect.Memo</div>
<div>@Prospect?.Memo</div>
<table>
<InteractionRow

View File

@@ -1,9 +1,19 @@
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Entity;
namespace FoodsharingSiegen.Server.Data
{
/// <summary>
/// The audit helper class (a. beging, 31.05.2022)
/// </summary>
public static class AuditHelper
{
#region Public Method CreateText
/// <summary>
/// Creates the text using the specified audit (a. beging, 31.05.2022)
/// </summary>
/// <param name="audit">The audit</param>
/// <returns>The string</returns>
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
}
}

View File

@@ -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)

View File

@@ -11,7 +11,7 @@ namespace FoodsharingSiegen.Server.Data.Service
/// <seealso cref="ServiceBase"/>
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<Interaction>(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<List<Prospect>>(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;

View File

@@ -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<User>(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<User>(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<List<User>>(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 ||

View File

@@ -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;

View File

@@ -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";

View File

@@ -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<User> 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 @@
<Field>
<FieldLabel>Passwort</FieldLabel>
<Validation Validator="ValidationHelper.ValidatePassword" @bind-Status="@IsValidPassword">
<TextEdit @bind-Text="Password" Role="TextRole.Password" Placeholder="Passwort"></TextEdit>
<TextEdit @bind-Text="Password" Placeholder="Passwort" Role="TextRole.Password"></TextEdit>
</Validation>
</Field>
<Field>
<FieldLabel>Passwort wiederholen</FieldLabel>
<Validation Validator="ValidationHelper.ValidatePassword" @bind-Status="@IsValidConfirm">
<TextEdit @bind-Text="ConfirmPassword" Role="TextRole.Password" Placeholder="Passwort"></TextEdit>
<TextEdit @bind-Text="ConfirmPassword" Placeholder="Passwort" Role="TextRole.Password"></TextEdit>
</Validation>
</Field>
</ModalBody>
<ModalFooter>
<Button Color="Color.Secondary" Clicked="ModalReference.Hide">Abbrechen</Button>
<Button Color="Color.Primary" Clicked="SaveClick" Disabled="@SaveDisabled">Speichern</Button>
<Button Clicked="ModalReference.Hide" Color="Color.Secondary">Abbrechen</Button>
<Button Clicked="SaveClick" Color="Color.Primary" Disabled="@SaveDisabled">Speichern</Button>
</ModalFooter>
</ModalContent>
</Modal>

View File

@@ -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
<div class="d-flex justify-content-center align-items-center" style="height: 100vh;">
<div class="card" style="width: 100%; max-width: 380px;">
<div class="card-header">FS Siegen</div>

View File

@@ -4,33 +4,32 @@ using Microsoft.AspNetCore.Components.Web;
namespace FoodsharingSiegen.Server.Pages
{
/// <summary>
/// The login class (a. beging, 11.04.2022)
/// The login class (a. beging, 11.04.2022)
/// </summary>
public partial class Login
{
#region Public Properties
/// <summary>
/// Gets or sets the value of the is valid mail (ab)
/// </summary>
public ValidationStatus IsValidMail { get; set; }
/// <summary>
/// Gets or sets the value of the is valid password (ab)
/// </summary>
public ValidationStatus IsValidPassword { get; set; }
#endregion
#region Private Properties
/// <summary>
/// Gets or sets the value of the mail-address (ab)
/// Gets or sets the value of the is valid mail (ab)
/// </summary>
private ValidationStatus IsValidMail { get; set; }
/// <summary>
/// Gets or sets the value of the is valid password (ab)
/// </summary>
private ValidationStatus IsValidPassword { get; set; }
/// <summary>
/// Gets or sets the value of the auth service (ab)
/// </summary>
/// <summary>
/// Gets or sets the value of the mail-address (ab)
/// </summary>
private string? MailAddress { get; set; }
/// <summary>
/// Gets or sets the value of the password (ab)
/// Gets or sets the value of the password (ab)
/// </summary>
private string? Password { get; set; }
@@ -39,7 +38,7 @@ namespace FoodsharingSiegen.Server.Pages
#region Private Method PerformLogin
/// <summary>
/// Performs the login (a. beging, 11.04.2022)
/// Performs the login (a. beging, 11.04.2022)
/// </summary>
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
/// <summary>
/// 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)
/// </summary>
/// <param name="arg">The arg</param>
private async Task TextEdit_KeyUp(KeyboardEventArgs arg)

View File

@@ -28,7 +28,7 @@
<h4>Aktuell:</h4>
<div class="row m-0">
<Repeater Items="@activeProspects">
<ProspectContainer Prospect="context" InteractionModal="InteractionModal" ProspectModal="ProspectModal" RemoveInteraction="@RemoveInteraction"></ProspectContainer>
<ProspectContainer Prospect="context" InteractionModal="InteractionModal" ProspectModal="ProspectModal" RemoveInteraction="RemoveInteraction"></ProspectContainer>
</Repeater>
</div>
}
@@ -43,7 +43,7 @@
<h4>Abgeschlossen:</h4>
<div class="row m-0">
<Repeater Items="@completedProspects">
<ProspectContainer Prospect="context" InteractionModal="InteractionModal" ProspectModal="ProspectModal" RemoveInteraction="@RemoveInteraction"></ProspectContainer>
<ProspectContainer Prospect="context" InteractionModal="InteractionModal" ProspectModal="ProspectModal" RemoveInteraction="RemoveInteraction"></ProspectContainer>
</Repeater>
</div>
}

View File

@@ -16,7 +16,7 @@ namespace FoodsharingSiegen.Server.Pages
/// <summary>
/// Gets or sets the value of the message service (ab)
/// </summary>
[Inject] IMessageService MessageService { get; set; }
[Inject] private IMessageService MessageService { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the prospect service (ab)
@@ -35,22 +35,22 @@ namespace FoodsharingSiegen.Server.Pages
/// <summary>
/// Gets or sets the value of the interaction modal (ab)
/// </summary>
public AddInteractionModal InteractionModal { get; set; }
private AddInteractionModal? InteractionModal { get; set; }
/// <summary>
/// Gets or sets the value of the prospect list (ab)
/// </summary>
public List<Prospect>? ProspectList { get; set; }
private List<Prospect>? ProspectList { get; set; }
/// <summary>
/// Gets or sets the value of the prospect modal (ab)
/// </summary>
public AddProspectModal ProspectModal { get; set; } = null!;
private AddProspectModal ProspectModal { get; set; } = null!;
/// <summary>
/// Gets or sets the value of the users (ab)
/// </summary>
public List<User>? Users { get; set; }
private List<User>? 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);

View File

@@ -27,7 +27,7 @@
<h2>Benutzerverwaltung <span style="font-size: .5em; line-height: 0;">Admin</span></h2>
<div class="my-2">
<Button Color="Color.Primary" Disabled="@(SelectedUser == null)" Clicked="() => PasswordModal.Show(SelectedUser!)"><i class="fa-solid fa-key"></i>&nbsp;setzen</Button>
<Button Color="Color.Primary" Disabled="@(SelectedUser == null)" Clicked="async () => await PasswordModal?.Show(SelectedUser!)!"><i class="fa-solid fa-key"></i>&nbsp;setzen</Button>
</div>
<DataGrid TItem="User"
@@ -39,7 +39,7 @@
RowInserted="RowInserted"
RowUpdated="RowUpdated"
@bind-SelectedRow="SelectedUser"
RowDoubleClicked="arg => UserDataGrid.Edit(arg.Item)"
RowDoubleClicked="arg => UserDataGrid?.Edit(arg.Item)!"
Editable
Responsive="true">
<DataGridColumns>

View File

@@ -28,7 +28,7 @@ namespace FoodsharingSiegen.Server.Pages
/// <summary>
/// Gets or sets the value of the password modal (ab)
/// </summary>
private SetPasswordModal PasswordModal { get; set; }
private SetPasswordModal? PasswordModal { get; set; }
/// <summary>
/// Gets or sets the value of the selected company texts (ab)
@@ -43,7 +43,7 @@ namespace FoodsharingSiegen.Server.Pages
/// <summary>
/// Gets or sets the value of the user data grid (ab)
/// </summary>
private DataGrid<User> UserDataGrid { get; set; }
private DataGrid<User>? UserDataGrid { get; set; }
/// <summary>
/// Gets the value of the user groups (ab)
@@ -96,9 +96,9 @@ namespace FoodsharingSiegen.Server.Pages
/// <param name="user">The user</param>
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