diff --git a/EnvelopeGenerator.Application/Contracts/IReceiverService.cs b/EnvelopeGenerator.Application/Contracts/IReceiverService.cs index 3c08f17b..c474363b 100644 --- a/EnvelopeGenerator.Application/Contracts/IReceiverService.cs +++ b/EnvelopeGenerator.Application/Contracts/IReceiverService.cs @@ -1,4 +1,5 @@ -using DigitalData.Core.Abstractions.Application; +using DigitalData.Core.Abstractions; +using DigitalData.Core.Abstractions.Application; using DigitalData.Core.DTO; using EnvelopeGenerator.Application.DTOs.Receiver; using EnvelopeGenerator.Domain.Entities; @@ -7,8 +8,10 @@ namespace EnvelopeGenerator.Application.Contracts { public interface IReceiverService : ICRUDService { - public Task> ReadByAsync(string? emailAddress = null, string? signature = null); + Task> ReadByAsync(string? emailAddress = null, string? signature = null); - public Task DeleteByAsync(string? emailAddress = null, string? signature = null); + Task DeleteByAsync(string? emailAddress = null, string? signature = null); + + Task UpdateAsync(TUpdateDto updateDto) where TUpdateDto : IUnique; } } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Services/ReceiverService.cs b/EnvelopeGenerator.Application/Services/ReceiverService.cs index 422f5c0f..97015953 100644 --- a/EnvelopeGenerator.Application/Services/ReceiverService.cs +++ b/EnvelopeGenerator.Application/Services/ReceiverService.cs @@ -5,6 +5,8 @@ using EnvelopeGenerator.Domain.Entities; using EnvelopeGenerator.Infrastructure.Contracts; using EnvelopeGenerator.Application.DTOs.Receiver; using DigitalData.Core.DTO; +using DigitalData.Core.Abstractions; +using Microsoft.Extensions.Logging; namespace EnvelopeGenerator.Application.Services { @@ -34,5 +36,17 @@ namespace EnvelopeGenerator.Application.Services return await _repository.DeleteAsync(rcv) ? Result.Success() : Result.Fail(); } + + public virtual async Task UpdateAsync(TUpdateDto updateDto) where TUpdateDto : IUnique + { + var val = await _repository.ReadByIdAsync(updateDto.Id); + if (val == null) + { + return Result.Fail().Notice(LogLevel.Warning, Flag.NotFound, $"{updateDto.Id} is not found in update process of {GetType()} entity."); + } + + var entity = _mapper.Map(updateDto, val); + return (await _repository.UpdateAsync(entity)) ? Result.Success() : Result.Fail(); + } } } \ No newline at end of file