Developer 02 cc01f57125 Refaktorisierung der Lokalisierung und DTO-Integration
- Ersetzung von ITranslateService durch IStringLocalizer<X> für verbesserte Lokalisierung.
- Aktualisierung der DTO-Klassen entsprechend der neuesten Core.DTO-Struktur.
- Integration der neuen Klassen Result und DataResult aus Core.DTO für standardisierte Serviceantworten.
2024-05-02 17:36:23 +02:00

41 lines
2.1 KiB
C#

using AutoMapper;
using DigitalData.Core.Application;
using DigitalData.Core.DTO;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using EnvelopeGenerator.Application.Resources;
namespace EnvelopeGenerator.Application.Services
{
public class EnvelopeService : BasicCRUDService<IEnvelopeRepository, EnvelopeDto, Envelope, int>, IEnvelopeService
{
private readonly ILogger _logger;
public EnvelopeService(IEnvelopeRepository repository, IStringLocalizer<Resource> localizer, IMapper mapper, ILogger<EnvelopeService> logger)
: base(repository, localizer, mapper)
{
_logger = logger;
}
public async Task<DataResult<IEnumerable<EnvelopeDto>>> ReadAllWithAsync(bool documents = false, bool envelopeReceivers = false, bool history = false, bool documentReceiverElement = false)
{
var envelopes = await _repository.ReadAllWithAsync(documents: documents, envelopeReceivers: envelopeReceivers, history: history, documentReceiverElement: documentReceiverElement);
var readDto = _mapper.MapOrThrow<IEnumerable<EnvelopeDto>>(envelopes);
return Result.Success(readDto);
}
public async Task<DataResult<EnvelopeDto>> ReadByUuidAsync(string uuid, string? signature = null, bool withDocuments = false, bool withEnvelopeReceivers = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false)
{
var envelope = await _repository.ReadByUuidAsync(uuid: uuid, signature: signature, withDocuments: withDocuments, withEnvelopeReceivers: withEnvelopeReceivers, withHistory: withHistory, withDocumentReceiverElement: withDocumentReceiverElement, withUser:withUser, withAll:withAll);
if (envelope is null)
return Result.Fail<EnvelopeDto>();
var readDto = _mapper.MapOrThrow<EnvelopeDto>(envelope);
return Result.Success(readDto);
}
}
}