protected override async Task OnInitializedAsync() { userId = base.Options; userEntity = await userService.FindAsync(userId); await base.OnInitializedAsync(); }
private async Task ValidatorByUsername(EditContext editContext) { // 强制设置为小写 userEntity.Username = userEntity.Username.Trim().ToLower(); SUserEntity other = await this.userService.FindByUsernameAsync(userEntity.Username); if (other != null && StringUtils.IsNotEqual(other.Id, userEntity.Id)) { messageStore.Add(editContext.Field(nameof(SUserEntity.Username)), "用户名不合法"); } }
protected override async Task OnInitializedAsync() { userId = base.Options ?? null; if (StringUtils.IsBlank(userId)) { userEntity = new SUserEntity(); } else { userEntity = await userService.FindCloneAsync(userId); // 如果是修改的情况这里要装假数据 // 不然验证通不过 userEntity.PasswordNew = "******"; userEntity.PasswordConfirm = userEntity.PasswordNew; } await base.OnInitializedAsync(); }