From 157d7b1d6e732bd4f6beb2b8ba2485c3e85b7f37 Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Fri, 23 Oct 2020 11:06:07 +0200 Subject: [PATCH] Use ObjectMapper for NewEntity and EditingEntity --- .../src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs index 7616447552..c6491f1ec1 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs @@ -318,7 +318,11 @@ namespace Volo.Abp.BlazoriseUI { await CheckCreatePolicyAsync(); - NewEntity.ResetState(); + ObjectMapper.Map(new TCreateViewModel(), NewEntity); + + // Mapper will not notify Blazor that binded values are changed + // so we need to notify it manually by calling StateHasChanged + await InvokeAsync(() => StateHasChanged()); CreateModal.Show(); } @@ -334,8 +338,12 @@ namespace Volo.Abp.BlazoriseUI await CheckUpdatePolicyAsync(); var entityDto = await AppService.GetAsync(id); + EditingEntityId = id; - EditingEntity.ApplyState(MapToEditingEntity(entityDto)); + ObjectMapper.Map(entityDto, EditingEntity); + + await InvokeAsync(() => StateHasChanged()); + EditModal.Show(); } @@ -379,8 +387,6 @@ namespace Volo.Abp.BlazoriseUI CreateModal.Hide(); } - - protected virtual async Task UpdateEntityAsync() { await CheckUpdatePolicyAsync();