59 lines
1.9 KiB
C#
59 lines
1.9 KiB
C#
using AutoMapper;
|
|
using DigitalData.Core.Application;
|
|
using EnvelopeGenerator.Domain.Entities;
|
|
using DigitalData.Core.Abstraction.Application.DTO;
|
|
using EnvelopeGenerator.Application.Receivers.Commands;
|
|
using EnvelopeGenerator.Application.Common.Dto.Receiver;
|
|
using EnvelopeGenerator.Application.Common.Interfaces.Repositories;
|
|
using EnvelopeGenerator.Application.Common.Interfaces.Services;
|
|
|
|
namespace EnvelopeGenerator.Application.Services;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
[Obsolete("Use MediatR")]
|
|
public class ReceiverService : CRUDService<IReceiverRepository, CreateReceiverCommand, ReceiverDto, Receiver, int>, IReceiverService
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="repository"></param>
|
|
/// <param name="mapper"></param>
|
|
public ReceiverService(IReceiverRepository repository, IMapper mapper)
|
|
: base(repository, mapper)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="emailAddress"></param>
|
|
/// <param name="signature"></param>
|
|
/// <returns></returns>
|
|
public async Task<DataResult<ReceiverDto>> ReadByAsync(string? emailAddress = null, string? signature = null)
|
|
{
|
|
var rcv = await _repository.ReadByAsync(emailAddress: emailAddress, signature: signature);
|
|
|
|
if (rcv is null)
|
|
return Result.Fail<ReceiverDto>();
|
|
|
|
return Result.Success(_mapper.Map<ReceiverDto>(rcv));
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="emailAddress"></param>
|
|
/// <param name="signature"></param>
|
|
/// <returns></returns>
|
|
public async Task<Result> DeleteByAsync(string? emailAddress = null, string? signature = null)
|
|
{
|
|
var rcv = await _repository.ReadByAsync(emailAddress: emailAddress, signature: signature);
|
|
|
|
if (rcv is null)
|
|
return Result.Fail();
|
|
|
|
return await _repository.DeleteAsync(rcv) ? Result.Success() : Result.Fail();
|
|
}
|
|
} |