diff --git a/src/Api.Crud.Client/Api.Crud.Client.csproj b/src/Api.Crud.Client/Api.Crud.Client.csproj index e639580..fcd0729 100644 --- a/src/Api.Crud.Client/Api.Crud.Client.csproj +++ b/src/Api.Crud.Client/Api.Crud.Client.csproj @@ -7,9 +7,9 @@ eQuantic.Core.Api.Crud.Client eQuantic.Core.Api.Crud.Client eQuantic.Core.Api.Crud.Client - 1.7.12.0 - 1.7.12.0 - 1.7.12.0 + 1.7.13.0 + 1.7.13.0 + 1.7.13.0 net7.0;net8.0 eQuantic.Core.Api.Crud.Client diff --git a/src/Api.Crud/Api.Crud.csproj b/src/Api.Crud/Api.Crud.csproj index fe7f8be..7f2ebf4 100644 --- a/src/Api.Crud/Api.Crud.csproj +++ b/src/Api.Crud/Api.Crud.csproj @@ -7,9 +7,9 @@ eQuantic.Core.Api.Crud eQuantic.Core.Api.Crud eQuantic.Core.Api.Crud - 1.7.12.0 - 1.7.12.0 - 1.7.12.0 + 1.7.13.0 + 1.7.13.0 + 1.7.13.0 net7.0;net8.0 eQuantic.Core.Api.Crud diff --git a/src/Application.Crud/Application.Crud.csproj b/src/Application.Crud/Application.Crud.csproj index e93f3d8..13281b4 100644 --- a/src/Application.Crud/Application.Crud.csproj +++ b/src/Application.Crud/Application.Crud.csproj @@ -7,9 +7,9 @@ eQuantic.Core.Application.Crud eQuantic.Core.Application.Crud eQuantic.Core.Application.Crud - 1.7.12.0 - 1.7.12.0 - 1.7.12.0 + 1.7.13.0 + 1.7.13.0 + 1.7.13.0 netstandard2.1;net7.0;net8.0 eQuantic.Core.Application.Crud diff --git a/src/Application.Crud/Services/CrudServiceBase.cs b/src/Application.Crud/Services/CrudServiceBase.cs index 64ce947..55dd2c2 100644 --- a/src/Application.Crud/Services/CrudServiceBase.cs +++ b/src/Application.Crud/Services/CrudServiceBase.cs @@ -56,9 +56,18 @@ public virtual async Task CreateAsync(CreateRequest request, Can var userId = await ApplicationContext.GetCurrentUserIdAsync(); itemWithOwner.CreatedById = userId; } - - await Repository.AddAsync(item); - await Repository.UnitOfWork.CommitAsync(cancellationToken); + + try + { + await Repository.AddAsync(item); + await Repository.UnitOfWork.CommitAsync(cancellationToken); + } + catch (Exception ex) + { + Logger.LogError(ex, "One error was occurred when creating '{EntityName}'", typeof(TEntity).Name); + throw; + } + await OnAfterCreateAsync(request, item, cancellationToken); return item.GetKey(); @@ -91,8 +100,17 @@ public virtual async Task UpdateAsync(UpdateRequest reques itemWithTrack.UpdatedById = userId; } - await Repository.ModifyAsync(item); - await Repository.UnitOfWork.CommitAsync(cancellationToken); + try + { + await Repository.ModifyAsync(item); + await Repository.UnitOfWork.CommitAsync(cancellationToken); + } + catch (Exception ex) + { + Logger.LogError(ex, "One error was occurred when updating '{EntityName}'", typeof(TEntity).Name); + throw; + } + await OnAfterUpdateAsync(request, item, cancellationToken); return true; @@ -126,16 +144,25 @@ public virtual async Task DeleteAsync(ItemRequest request, Cancellat itemWithHistory.DeletedById = userId; } - if (softDelete) + try { - await Repository.ModifyAsync(item); + if (softDelete) + { + await Repository.ModifyAsync(item); + } + else + { + await Repository.RemoveAsync(item); + } + + await Repository.UnitOfWork.CommitAsync(cancellationToken); } - else + catch (Exception ex) { - await Repository.RemoveAsync(item); + Logger.LogError(ex, "One error was occurred when deleting '{EntityName}'", typeof(TEntity).Name); + throw; } - await Repository.UnitOfWork.CommitAsync(cancellationToken); await OnAfterDeleteAsync(item, cancellationToken); return true;