!797 fix(#I2AGWM): throw exception when not register DataService and no OnAddAsync callback

* fix: 修复未开启 UseInjectDataService 未设置 OnAddAsync 时报错
This commit is contained in:
Argo 2020-12-23 01:03:45 +08:00
parent 42345e6b43
commit 0cf7f294ef

View File

@ -181,12 +181,19 @@ namespace BootstrapBlazor.Components
{
if (UseInjectDataService || OnSaveAsync != null)
{
if (OnAddAsync != null) EditModel = await OnAddAsync();
else
if (OnAddAsync != null)
{
EditModel = await OnAddAsync();
}
else if (UseInjectDataService)
{
EditModel = new TItem();
await GetDataService().AddAsync(EditModel);
}
else
{
EditModel = new TItem();
}
SelectedItems.Clear();
EditModalTitleString = AddModalTitle;