@inherits UserPointManagement.Web.Pages.UserPointPage.UserPointDetailBase
@page "/user-point"
@using System.ComponentModel.DataAnnotations
@using System.Text.Json
@using global::UserPointManagement.Model.Dtos.User
@using global::UserPointManagement.Model.Dtos.UserPoint
@using UserPointManagement.Application.Services
@inject IUserPointService UserPointService;
@code {
#region original form coding
public class Model
{
[Required]
public int UserId { get; set; }
[Required]
public int Point { 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 UserPointService.CreateUserPoint(new CreateUserPointDto()
{
UserId = model.UserId,
Point = model.Point
}).ConfigureAwait(false);
await RefreshTable().ConfigureAwait(false);
}
}