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();
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);
}

8
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);
}

Loading…
Cancel
Save