Developer 02 ab713a23ac Feature-Update: Erweiterung der Envelope- und DocumentReceiverElement-Abfragen
Die Methoden `ReadAllWithAsync` und `ReadByUuidAsync` in `EnvelopeRepository` wurden erweitert, um optional DocumentReceiverElemente und Signaturdetails einzubeziehen.
2024-04-05 16:54:29 +02:00

37 lines
1.8 KiB
C#

using AutoMapper;
using DigitalData.Core.Application;
using DigitalData.Core.Contracts.Application;
using DigitalData.Core.Contracts.CultureServices;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Services
{
public class EnvelopeService : BasicCRUDService<IEnvelopeRepository, EnvelopeDto, Envelope, int>, IEnvelopeService
{
public EnvelopeService(IEnvelopeRepository repository, IKeyTranslationService translationService, IMapper mapper)
: base(repository, translationService, mapper)
{
}
public async Task<IServiceResult<IEnumerable<EnvelopeDto>>> ReadAllWithAsync(bool documents = false, bool receivers = false, bool history = false, bool documentReceiverElement = false)
{
var envelopes = await _repository.ReadAllWithAsync(documents: documents, receivers: receivers, history: history, documentReceiverElement: documentReceiverElement);
var readDto = _mapper.MapOrThrow<IEnumerable<EnvelopeDto>>(envelopes);
return Successful(readDto);
}
public async Task<IServiceResult<EnvelopeDto>> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withReceivers = false, bool withHistory = false, bool withDocumentReceiverElement = false)
{
var envelope = await _repository.ReadByUuidAsync(uuid: uuid, withDocuments: withDocuments, withReceivers: withReceivers, withHistory: withHistory, withDocumentReceiverElement: withDocumentReceiverElement);
if (envelope is null)
return Failed<EnvelopeDto>();
var readDto = _mapper.MapOrThrow<EnvelopeDto>(envelope);
return Successful(readDto);
}
}
}