Browse Source

Use autoSave option instead of manually calling CurrentUnitOfWork.SaveChanges.

pull/1093/head
Halil ibrahim Kalkan 7 years ago
parent
commit
3fc8f26e35
  1. 9
      framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AsyncCrudAppService.cs
  2. 8
      framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs

9
framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/AsyncCrudAppService.cs

@ -90,9 +90,7 @@ namespace Volo.Abp.Application.Services
await CheckCreatePolicyAsync(); await CheckCreatePolicyAsync();
var entity = MapToEntity(input); var entity = MapToEntity(input);
await Repository.InsertAsync(entity, autoSave: true);
await Repository.InsertAsync(entity);
await CurrentUnitOfWork.SaveChangesAsync();
return MapToEntityDto(entity); return MapToEntityDto(entity);
} }
@ -102,12 +100,9 @@ namespace Volo.Abp.Application.Services
await CheckUpdatePolicyAsync(); await CheckUpdatePolicyAsync();
var entity = await GetEntityByIdAsync(id); 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 //TODO: Check if input has id different than given id and normalize if it's default value, throw ex otherwise
MapToEntity(input, entity); MapToEntity(input, entity);
await Repository.UpdateAsync(entity); await Repository.UpdateAsync(entity, autoSave: true);
await CurrentUnitOfWork.SaveChangesAsync();
return MapToEntityDto(entity); return MapToEntityDto(entity);
} }

8
framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/CrudAppService.cs

@ -86,9 +86,7 @@ namespace Volo.Abp.Application.Services
CheckCreatePolicy(); CheckCreatePolicy();
var entity = MapToEntity(input); var entity = MapToEntity(input);
Repository.Insert(entity, autoSave: true);
Repository.Insert(entity);
CurrentUnitOfWork.SaveChanges();
return MapToEntityDto(entity); return MapToEntityDto(entity);
} }
@ -98,10 +96,8 @@ namespace Volo.Abp.Application.Services
CheckUpdatePolicy(); CheckUpdatePolicy();
var entity = GetEntityById(id); var entity = GetEntityById(id);
MapToEntity(input, entity); MapToEntity(input, entity);
Repository.Update(entity); Repository.Update(entity, autoSave: true);
CurrentUnitOfWork.SaveChanges();
return MapToEntityDto(entity); return MapToEntityDto(entity);
} }

Loading…
Cancel
Save