From 8e1b4e0832128488ab67f848eee2d2bf9bc71e70 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Tue, 10 Dec 2024 23:48:01 +0100 Subject: [PATCH] =?UTF-8?q?feat(ReceiverService):=20Generische=20Update-Me?= =?UTF-8?q?thode=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Contracts/IReceiverService.cs | 9 ++++++--- .../Services/ReceiverService.cs | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) 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