- InitializeAsync in InitializeSafeAsync mit Fehlerbehandlung umbenannt, App-Start robuster gestaltet - Asynchrone Initialisierung bei Window.Created - Navigation vereinheitlicht: Routing.RegisterRoute statt Doppelslash, Navigation ohne Präfix - Flyout-Menü in AppShell deaktiviert, ShellContent-Einträge entfernt - Login/Register-ViewModels nutzen private Felder statt ObservableProperty - SignalRService nutzt AccessToken aus AuthSessionService - GameStateService: Automatischer Resync bei Verbindung, Fehlerhandling verbessert - Navigation in ViewModels an neues Routing angepasst - Aufräumarbeiten: Entfernte auskommentierte Messenger-Registrierungen, Initialisierung vereinheitlicht
52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using SlipItIn.Services.Interfaces;
|
|
using SlipItIn.Shared.DTOs;
|
|
using SlipItIn.Views;
|
|
|
|
namespace SlipItIn.ViewModels;
|
|
|
|
public partial class RegisterViewModel : BaseViewModel
|
|
{
|
|
private readonly IApiService _apiService;
|
|
private readonly IAuthSessionService _authSession;
|
|
private readonly ISignalRService _signalR;
|
|
|
|
[ObservableProperty]
|
|
private string username = string.Empty;
|
|
|
|
[ObservableProperty]
|
|
private string email = string.Empty;
|
|
|
|
[ObservableProperty]
|
|
private string password = string.Empty;
|
|
|
|
public RegisterViewModel(IApiService apiService, IAuthSessionService authSession, ISignalRService signalR)
|
|
{
|
|
_apiService = apiService;
|
|
_authSession = authSession;
|
|
_signalR = signalR;
|
|
}
|
|
|
|
[RelayCommand]
|
|
private Task BackToLoginAsync() => Shell.Current.GoToAsync($"//{nameof(LoginPage)}");
|
|
|
|
[RelayCommand]
|
|
private async Task RegisterAsync()
|
|
{
|
|
await RunSafeAsync(async () =>
|
|
{
|
|
var response = await _apiService.RegisterAsync(new RegisterRequestDto
|
|
{
|
|
Username = Username,
|
|
Email = Email,
|
|
Password = Password
|
|
});
|
|
|
|
await _authSession.SetSessionAsync(response);
|
|
await _signalR.ConnectAsync(response.Token);
|
|
await Shell.Current.GoToAsync(nameof(LobbyPage));
|
|
}, "Registrierung läuft...");
|
|
}
|
|
}
|