From 3fc8f26e352ae2fa663b4e4af61fe256dd38a1ce Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Sun, 5 May 2019 21:40:48 +0300 Subject: [PATCH] Use autoSave option instead of manually calling CurrentUnitOfWork.SaveChanges. --- .../Volo/Abp/Application/Services/AsyncCrudAppService.cs | 9 ++------- .../Volo/Abp/Application/Services/CrudAppService.cs | 8 ++------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AsyncCrudAppService.cs b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AsyncCrudAppService.cs index bf769dc78b..3d633931b3 100644 --- a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AsyncCrudAppService.cs +++ b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AsyncCrudAppService.cs @@ -90,9 +90,7 @@ namespace Volo.Abp.Application.Services await CheckCreatePolicyAsync(); var entity = MapToEntity(input); - - await Repository.InsertAsync(entity); - await CurrentUnitOfWork.SaveChangesAsync(); + await Repository.InsertAsync(entity, autoSave: true); return MapToEntityDto(entity); } @@ -102,12 +100,9 @@ namespace Volo.Abp.Application.Services await CheckUpdatePolicyAsync(); var entity = await GetEntityByIdAsync(id); - //TODO: Check if input has id different than given id and normalize if it's default value, throw ex otherwise - MapToEntity(input, entity); - await Repository.UpdateAsync(entity); - await CurrentUnitOfWork.SaveChangesAsync(); + await Repository.UpdateAsync(entity, autoSave: true); return MapToEntityDto(entity); } diff --git a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs index 60017e918f..2750d699a4 100644 --- a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs +++ b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs @@ -86,9 +86,7 @@ namespace Volo.Abp.Application.Services CheckCreatePolicy(); var entity = MapToEntity(input); - - Repository.Insert(entity); - CurrentUnitOfWork.SaveChanges(); + Repository.Insert(entity, autoSave: true); return MapToEntityDto(entity); } @@ -98,10 +96,8 @@ namespace Volo.Abp.Application.Services CheckUpdatePolicy(); var entity = GetEntityById(id); - MapToEntity(input, entity); - Repository.Update(entity); - CurrentUnitOfWork.SaveChanges(); + Repository.Update(entity, autoSave: true); return MapToEntityDto(entity); }