添加项目文件。
This commit is contained in:
58
TechHelper.Client/Pages/Manage/Class.razor
Normal file
58
TechHelper.Client/Pages/Manage/Class.razor
Normal file
@@ -0,0 +1,58 @@
|
||||
@page "/Account/Manage/Class"
|
||||
@using System.ComponentModel.DataAnnotations
|
||||
@using Entities.Contracts
|
||||
@using Microsoft.AspNetCore.Identity
|
||||
|
||||
|
||||
<PageTitle>Profile</PageTitle>
|
||||
|
||||
@if (authenticationStateTask.Result.User.FindFirst("Class")?.Value == null)
|
||||
{
|
||||
|
||||
<EditForm Model="@_userRegistrationToClassDto" OnValidSubmit="Register" FormName="ClassForm">
|
||||
<DataAnnotationsValidator />
|
||||
<MudGrid>
|
||||
<MudItem xs="12" sm="7">
|
||||
<MudCard>
|
||||
<MudCardContent>
|
||||
<MudRadioGroup T="UserRoles" Label="Roles" @bind-Value="_userRegistrationToClassDto.Roles">
|
||||
@foreach (UserRoles item in Enum.GetValues(typeof(UserRoles)))
|
||||
{
|
||||
if (item != UserRoles.Administrator)
|
||||
{
|
||||
<MudRadio Value="@item">@item.ToString()</MudRadio>
|
||||
}
|
||||
}
|
||||
</MudRadioGroup>
|
||||
<MudTextField Label="Grade" Class="mt-3"
|
||||
@bind-Value="_userRegistrationToClassDto.GradeId" For="@(() => _userRegistrationToClassDto.GradeId)" />
|
||||
<MudTextField Label="Class" HelperText="请输入你的班级" Class="mt-3"
|
||||
@bind-Value="_userRegistrationToClassDto.ClassId" For="@(() => _userRegistrationToClassDto.ClassId)" />
|
||||
|
||||
@if (_userRegistrationToClassDto.Roles == UserRoles.Teacher)
|
||||
{
|
||||
<MudSelect @bind-Value="_userRegistrationToClassDto.SubjectArea" Label="Select Subject" AdornmentColor="Color.Secondary">
|
||||
@foreach (SubjectAreaEnum item in Enum.GetValues(typeof(SubjectAreaEnum)))
|
||||
{
|
||||
<MudSelectItem Value="@item">@item</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
}
|
||||
</MudCardContent>
|
||||
<MudCardActions>
|
||||
<MudButton ButtonType="ButtonType.Submit" Variant="Variant.Filled" Color="Color.Primary" Class="ml-auto">Register</MudButton>
|
||||
</MudCardActions>
|
||||
</MudCard>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</EditForm>
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudPaper>
|
||||
<MudText Class="ma-3 pa-3"> 年级 : @authenticationStateTask.Result.User.FindFirst("Grade")?.Value.ToString() </MudText>
|
||||
<MudText Class="ma-3 pa-3"> 班级 : @authenticationStateTask.Result.User.FindFirst("Class")?.Value.ToString() </MudText>
|
||||
</MudPaper>
|
||||
}
|
62
TechHelper.Client/Pages/Manage/Class.razor.cs
Normal file
62
TechHelper.Client/Pages/Manage/Class.razor.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
}
|
60
TechHelper.Client/Pages/Manage/Index.razor
Normal file
60
TechHelper.Client/Pages/Manage/Index.razor
Normal file
@@ -0,0 +1,60 @@
|
||||
@page "/Account/Manage"
|
||||
|
||||
@using System.ComponentModel.DataAnnotations
|
||||
@using Microsoft.AspNetCore.Identity
|
||||
|
||||
|
||||
<PageTitle>Profile</PageTitle>
|
||||
|
||||
<h3>Profile</h3>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<EditForm Model="Input" FormName="profile" OnValidSubmit="OnValidSubmitAsync" method="post">
|
||||
<DataAnnotationsValidator />
|
||||
<ValidationSummary class="text-danger" role="alert" />
|
||||
<div class="form-floating mb-3">
|
||||
<input type="text" value="@username" class="form-control" placeholder="Please choose your username." disabled />
|
||||
<label for="username" class="form-label">Username</label>
|
||||
</div>
|
||||
<div class="form-floating mb-3">
|
||||
<InputText @bind-Value="Input.PhoneNumber" class="form-control" placeholder="Please enter your phone number." />
|
||||
<label for="phone-number" class="form-label">Phone number</label>
|
||||
<ValidationMessage For="() => Input.PhoneNumber" class="text-danger" />
|
||||
</div>
|
||||
<button type="submit" class="w-100 btn btn-lg btn-primary">Save</button>
|
||||
</EditForm>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
private string? username;
|
||||
private string? phoneNumber;
|
||||
|
||||
[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 OnValidSubmitAsync()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private sealed class InputModel
|
||||
{
|
||||
[Phone]
|
||||
[Display(Name = "Phone number")]
|
||||
public string? PhoneNumber { get; set; }
|
||||
}
|
||||
}
|
30
TechHelper.Client/Pages/Manage/PersonalData.razor
Normal file
30
TechHelper.Client/Pages/Manage/PersonalData.razor
Normal file
@@ -0,0 +1,30 @@
|
||||
@page "/Account/Manage/PersonalData"
|
||||
|
||||
|
||||
<PageTitle>Personal Data</PageTitle>
|
||||
|
||||
<h3>Personal Data</h3>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<p>Your account contains personal data that you have given us. This page allows you to download or delete that data.</p>
|
||||
<p>
|
||||
<strong>Deleting this data will permanently remove your account, and this cannot be recovered.</strong>
|
||||
</p>
|
||||
<form action="Account/Manage/DownloadPersonalData" method="post">
|
||||
<AntiforgeryToken />
|
||||
<button class="btn btn-primary" type="submit">Download</button>
|
||||
</form>
|
||||
<p>
|
||||
<a href="Account/Manage/DeletePersonalData" class="btn btn-danger">Delete</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
2
TechHelper.Client/Pages/Manage/_Imports.razor
Normal file
2
TechHelper.Client/Pages/Manage/_Imports.razor
Normal file
@@ -0,0 +1,2 @@
|
||||
@using TechHelper.Client.Shared
|
||||
@layout ManageLayout
|
Reference in New Issue
Block a user