浏览代码

优化注册逻辑

宝臣 王 3 月之前
父节点
当前提交
4276088efe
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      UniformMaterialManagementSystem/ViewModels/RegisterPageViewModel.cs

+ 3 - 3
UniformMaterialManagementSystem/ViewModels/RegisterPageViewModel.cs

@@ -39,7 +39,7 @@ namespace UniformMaterialManagementSystem.ViewModels
         private ICollection<Company> _companyList = [];
 
         [ObservableProperty]
-        private Company _selectedCompany = null!;
+        private Company? _selectedCompany;
 
         [ObservableProperty]
         [Required(ErrorMessage = "用户名不能为空")]
@@ -87,9 +87,9 @@ namespace UniformMaterialManagementSystem.ViewModels
                 Password = PasswordHashing.GenerateSaltedHash(Password, salt),
                 UserName = UserName,
                 LoginName = UserName,
-                CompanyGuid = SelectedCompany.Guid,
+                CompanyGuid = SelectedCompany?.Guid,
                 Company = SelectedCompany,
-                CompanyName = SelectedCompany.Name,
+                CompanyName = SelectedCompany?.Name,
                 IsEnabled = true,
                 RegisterDate = DateTime.Now,
                 Roles = [_roles[SelectedUnitType]],