添加项目文件。

This commit is contained in:
SpecialX
2025-05-23 19:03:00 +08:00
parent 6fa7679fd3
commit d36fef2bbb
185 changed files with 13413 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
using Entities.DTO;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using MudBlazor;
using System.Collections.Frozen;
using System.ComponentModel.DataAnnotations;
using TechHelper.Client.HttpRepository;
using TechHelper.Client.Services;
namespace TechHelper.Client.Pages.Manage
{
public partial class Class
{
private UserRegistrationToClassDto _userRegistrationToClassDto = new UserRegistrationToClassDto();
private string? username;
private string? phoneNumber;
[Inject]
public ISnackbar Snackbar { get; set; }
[Inject]
public IAuthenticationClientService Authentication { get; set; }
[Inject]
public IClassServices ClassServices { get; set; }
[CascadingParameter]
private Task<AuthenticationState> authenticationStateTask { get; set; }
[SupplyParameterFromForm]
private InputModel Input { get; set; } = new();
protected override async Task OnInitializedAsync()
{
username = authenticationStateTask.Result.User.Identity.Name;
phoneNumber = authenticationStateTask.Result.User.Identity.IsAuthenticated.ToString();
Input.PhoneNumber ??= phoneNumber;
}
private async Task Register()
{
_userRegistrationToClassDto.User = authenticationStateTask.Result.User.Identity.Name?? "";
var result = await ClassServices.UserRegister(_userRegistrationToClassDto);
if (result.IsSuccessfulRegistration)
{
var token = await Authentication.RefreshTokenAsync();
Snackbar.Add("<22>༶ע<E0BCB6><D7A2><EFBFBD>ɹ<EFBFBD>", Severity.Info);
}
else
{
Snackbar.Add(result.Errors.First(), Severity.Error);
}
}
private sealed class InputModel
{
[Phone]
[Display(Name = "Phone number")]
public string? PhoneNumber { get; set; }
}
}
}