@inherits MyAntDesignAppServer.Pages.UserManagement.UserManagementBase @page "/" @using UserPointManagement.Application.Services @using UserPointManagement.Model.Dtos @using UserPointManagement.Model.Entities @using System.ComponentModel.DataAnnotations @using System.Text.Json @inject IJSRuntime JS @inject IUserService UserService;
@code { #region original form coding public class Model { [Required] public string Name { get; set; } public string Mobile { get; set; } } private Model model = new Model(); private void OnFinishFailed(EditContext editContext) { Console.WriteLine($"Failed:{JsonSerializer.Serialize(model)}"); } bool loading = false; void toggle(bool value) => loading = value; #endregion #region original modal coding bool _visible = false; private void ShowModal() { _visible = true; } private void HandleCancel(MouseEventArgs e) { _visible = false; } #endregion /* * Careful! * * next bind submit event to modal OK button */ private Form _form; /// /// when form is submited, close the modal /// /// private void OnFinish(EditContext editContext) { Console.WriteLine("e"); _visible = false; } /// /// on modal OK button is click, submit form manually /// /// private async Task HandleOk(MouseEventArgs e) { _form.Submit(); await UserService.CreateUser(new User() { Name = model.Name, Mobile = model.Mobile }).ConfigureAwait(false); await RefreshTable().ConfigureAwait(false); } }