Compare commits
117 Commits
feat/read-
...
8a4d3ff6f9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a4d3ff6f9 | ||
|
|
783d91a658 | ||
|
|
ad032b2bdf | ||
|
|
f2876d8995 | ||
|
|
5468d7b2aa | ||
|
|
b005c194d3 | ||
|
|
dee6608390 | ||
|
|
8b53eae6da | ||
|
|
405b619bdc | ||
|
|
c5918b8e49 | ||
|
|
05cd8a05f4 | ||
|
|
2355a566e4 | ||
|
|
c887f857cd | ||
|
|
f114144d34 | ||
|
|
5c09601e3f | ||
|
|
18b05a3c63 | ||
|
|
ce35b0fea1 | ||
|
|
7f18cd64c5 | ||
|
|
0083c1b6c1 | ||
| 59e73dbcf0 | |||
| f34770931f | |||
| 78100ef24f | |||
| 99083a68aa | |||
| 0939e57c56 | |||
| 00bdfeb9bb | |||
| cced0e5579 | |||
| 82150290d2 | |||
| fb7fd47a2a | |||
| 20b6b328f5 | |||
| fb07d9151f | |||
| a3bc26bd08 | |||
| e1f793e571 | |||
| 86d8fcda07 | |||
| 2f8401073f | |||
| 85a855fe64 | |||
| 996b544633 | |||
| 811656c4ca | |||
| 7e90d25f0b | |||
| 20751aa708 | |||
| 51b96e2a81 | |||
| 7a011930df | |||
| a080aaec95 | |||
| d390802305 | |||
| 0b33ba0fd8 | |||
| 6778d8e3e7 | |||
| 3394a580f4 | |||
| 82a63b0dae | |||
| e61d626bf3 | |||
| bd7c1d4e36 | |||
| 30e2ac602d | |||
| 1577440b77 | |||
| 68a6a23a20 | |||
| 5e5458d87c | |||
| eae83adee4 | |||
| a29785f7c7 | |||
| cb641fd33a | |||
| 9434832261 | |||
| b7e19db0f1 | |||
| 290e87048c | |||
| c0a5b57668 | |||
| 02ef05f054 | |||
| 72134c3d3b | |||
| a4fffaa9b9 | |||
| 3a62f5317f | |||
| 59c93de8b7 | |||
| 5122a2099d | |||
| 95ec19d816 | |||
| c7b3d97b2e | |||
| 196941f73f | |||
| 415fe646b2 | |||
| f42218802d | |||
| fcf00171de | |||
| ca28c4cca4 | |||
| a48e4988d6 | |||
| ec513716ff | |||
| f39b761412 | |||
| 70d122d2ff | |||
| 5bc5fcf764 | |||
| 8db62b41ba | |||
| 0f27600c5b | |||
| 9045655262 | |||
| 5bcac264a7 | |||
| c7bf800cd5 | |||
| 5fb4d03ee7 | |||
| ac70aaa527 | |||
| e877000b14 | |||
| 305422688e | |||
| 9c6135d208 | |||
| 903e4678ed | |||
| 730a318b56 | |||
| 55c0f44954 | |||
| dbb745338c | |||
| 419f421d52 | |||
| e64ac4b5e7 | |||
| d8200993af | |||
| ee98142405 | |||
| c27337a6f5 | |||
| a09ea990ab | |||
| 05888bc57d | |||
| 39af0fe4fd | |||
| f4c61e3bc7 | |||
| 3f5a584399 | |||
| 6aec854a64 | |||
| c360bde103 | |||
| 82d4b0e740 | |||
| 12519f06f7 | |||
| a2471a0c35 | |||
| 4251a24fe9 | |||
| 63a830c8e3 | |||
| acee28ffce | |||
| 50a541c5bf | |||
| d43877db62 | |||
| 242e66cd8d | |||
| e44fa0b7bd | |||
| 4201f7820a | |||
| e095074c22 | |||
| 412f19547f |
@@ -1,12 +0,0 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Obsolete("Use Read-method returning IReadQuery<TEntity> instead.")]
|
||||
public interface IEnvelopeCertificateRepository : ICRUDRepository<EnvelopeCertificate, int>
|
||||
{
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using DigitalData.Core.Abstraction.Application;
|
||||
using EnvelopeGenerator.Application.DTOs;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Obsolete("Use MediatR")]
|
||||
public interface IEnvelopeCertificateService : IBasicCRUDService<EnvelopeCertificateDto, EnvelopeCertificate, int>
|
||||
{
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs;
|
||||
|
||||
/// <summary>
|
||||
/// Data Transfer Object representing certificate information for an envelope.
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
public class EnvelopeCertificateDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the unique identifier of the certificate.
|
||||
/// </summary>
|
||||
public int Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the envelope ID associated with the certificate.
|
||||
/// </summary>
|
||||
public int EnvelopeId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the UUID of the envelope.
|
||||
/// </summary>
|
||||
public string EnvelopeUuid { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the subject of the envelope.
|
||||
/// </summary>
|
||||
public string EnvelopeSubject { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ID of the creator of the envelope.
|
||||
/// </summary>
|
||||
public int CreatorId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the creator.
|
||||
/// </summary>
|
||||
public string CreatorName { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the email address of the creator.
|
||||
/// </summary>
|
||||
public string CreatorEmail { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current status of the envelope.
|
||||
/// </summary>
|
||||
public int EnvelopeStatus { get; init; }
|
||||
}
|
||||
@@ -5,9 +5,9 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using DigitalData.Core.Client;
|
||||
using QRCoder;
|
||||
using EnvelopeGenerator.Application.Contracts.Services;
|
||||
using EnvelopeGenerator.Application.Interfaces.Services;
|
||||
using System.Reflection;
|
||||
using EnvelopeGenerator.Application.EnvelopeReceivers.Commands.Create;
|
||||
using EnvelopeGenerator.Application.EnvelopeReceivers.Commands;
|
||||
|
||||
namespace EnvelopeGenerator.Application;
|
||||
|
||||
@@ -33,7 +33,6 @@ public static class DependencyInjection
|
||||
services.TryAddScoped<IDocumentStatusService, DocumentStatusService>();
|
||||
services.TryAddScoped<IEmailTemplateService, EmailTemplateService>();
|
||||
services.TryAddScoped<IEnvelopeService, EnvelopeService>();
|
||||
services.TryAddScoped<IEnvelopeCertificateService, EnvelopeCertificateService>();
|
||||
services.TryAddScoped<IEnvelopeDocumentService, EnvelopeDocumentService>();
|
||||
services.TryAddScoped<IEnvelopeReceiverService, EnvelopeReceiverService>();
|
||||
services.TryAddScoped<IEnvelopeTypeService, EnvelopeTypeService>();
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace EnvelopeGenerator.Application.DocStatus.Commands;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public record CreateDocStatusCommand : ModifyDocStatusCommandBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets timestamp when this record was added. Returns the StatusChangedWhen value.
|
||||
/// </summary>
|
||||
public DateTime AddedWhen => StatusChangedWhen;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using EnvelopeGenerator.Application.Model;
|
||||
using EnvelopeGenerator.Domain;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DocStatus.Commands;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public record ModifyDocStatusCommandBase : EnvelopeReceiverQueryBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the current status code.
|
||||
/// </summary>
|
||||
public Constants.DocumentStatus Status => Value is null ? Constants.DocumentStatus.Created : Constants.DocumentStatus.Signed;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the display value associated with the status.
|
||||
/// </summary>
|
||||
public string? Value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets timestamp when this record was added.
|
||||
/// </summary>
|
||||
public DateTime StatusChangedWhen { get; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Maps the current command to a new instance of the specified type.
|
||||
/// </summary>
|
||||
/// <typeparam name="TDest"></typeparam>
|
||||
/// <returns></returns>
|
||||
public TDest To<TDest>() where TDest : ModifyDocStatusCommandBase, new()
|
||||
=> new()
|
||||
{
|
||||
Key = Key,
|
||||
Envelope = Envelope,
|
||||
Receiver = Receiver,
|
||||
Value = Value
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DocStatus.Commands;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a command to save the status of a document, either by creating a new status or updating an existing one based on the provided envelope and receiver identifiers.
|
||||
/// It returns the identifier of the saved document status.
|
||||
/// </summary>
|
||||
public record SaveDocStatusCommand : ModifyDocStatusCommandBase, IRequest<int?>;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class Extensions
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="mediator"></param>
|
||||
/// <param name="uuid"></param>
|
||||
/// <param name="signature"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
public static Task<int?> SignDocAsync(this IMediator mediator, string uuid, string signature, string value, CancellationToken cancel = default)
|
||||
=> mediator.Send(new SaveDocStatusCommand()
|
||||
{
|
||||
Envelope = new() { Uuid = uuid },
|
||||
Receiver = new() { Signature = signature },
|
||||
Value = value
|
||||
}, cancel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class SaveDocStatusCommandHandler : IRequestHandler<SaveDocStatusCommand, int?>
|
||||
{
|
||||
private readonly IRepository<DocumentStatus> _repo;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="repo"></param>
|
||||
public SaveDocStatusCommandHandler(IRepository<DocumentStatus> repo)
|
||||
{
|
||||
_repo = repo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int?> Handle(SaveDocStatusCommand request, CancellationToken cancel)
|
||||
{
|
||||
// ceck if exists
|
||||
bool isExists = await _repo.ReadOnly().Where(request).AnyAsync(cancel);
|
||||
|
||||
if (isExists)
|
||||
{
|
||||
var uReq = request.To<UpdateDocStatusCommand>();
|
||||
await _repo.UpdateAsync(uReq, q => q.Where(request), cancel);
|
||||
}
|
||||
else
|
||||
{
|
||||
var cReq = request.To<CreateDocStatusCommand>();
|
||||
await _repo.CreateAsync(cReq, cancel);
|
||||
}
|
||||
|
||||
var docStatus = await _repo.ReadOnly().Where(request).SingleOrDefaultAsync(cancel);
|
||||
return docStatus?.Id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using EnvelopeGenerator.Domain;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DocStatus.Commands;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public record UpdateDocStatusCommand : ModifyDocStatusCommandBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets timestamp when this record was added. Returns the StatusChangedWhen value.
|
||||
/// </summary>
|
||||
public DateTime? ChangedWhen => StatusChangedWhen;
|
||||
}
|
||||
20
EnvelopeGenerator.Application/DocStatus/MappingProfile.cs
Normal file
20
EnvelopeGenerator.Application/DocStatus/MappingProfile.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.DocStatus.Commands;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DocStatus;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class MappingProfile : Profile
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public MappingProfile()
|
||||
{
|
||||
CreateMap<CreateDocStatusCommand, DocumentStatus>();
|
||||
CreateMap<UpdateDocStatusCommand, DocumentStatus>();
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Documents.Queries.Read;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ReadDocumentMappingProfile : Profile
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public ReadDocumentMappingProfile()
|
||||
{
|
||||
CreateMap<EnvelopeDocument, ReadDocumentResponse>();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Documents.Queries.Read;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a query to read a document based on its unique identifier or associated envelope identifier.
|
||||
/// </summary>
|
||||
/// <param name="Id">The unique identifier of the document. Optional.</param>
|
||||
/// <param name="EnvelopeId">The identifier of the envelope associated with the document. Optional.</param>
|
||||
public record ReadDocumentQuery(int? Id = null, int? EnvelopeId = null) : IRequest<ReadDocumentResponse?>
|
||||
{
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace EnvelopeGenerator.Application.Documents.Queries.Read;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the response for reading a document.
|
||||
/// </summary>
|
||||
public class ReadDocumentResponse : ReadDocumentResponseBase
|
||||
{
|
||||
/// <summary>
|
||||
/// The binary data of the document, if available.
|
||||
/// </summary>
|
||||
public byte[]? ByteData { get; init; }
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
namespace EnvelopeGenerator.Application.Documents.Queries.Read;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the response for reading a document.
|
||||
/// </summary>
|
||||
public class ReadDocumentResponseBase
|
||||
{
|
||||
/// <summary>
|
||||
/// The unique identifier of the document.
|
||||
/// </summary>
|
||||
public int Guid { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The identifier of the associated envelope.
|
||||
/// </summary>
|
||||
public int EnvelopeId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The date and time when the document was added.
|
||||
/// </summary>
|
||||
public DateTime AddedWhen { get; init; }
|
||||
}
|
||||
@@ -1,48 +1,69 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using EnvelopeGenerator.Application.Dto;
|
||||
using MediatR;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using AutoMapper;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Documents.Queries.Read;
|
||||
namespace EnvelopeGenerator.Application.Documents.Queries;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a query to read a document based on its unique identifier or associated envelope identifier.
|
||||
/// </summary>
|
||||
/// <param name="Id">The unique identifier of the document. Optional.</param>
|
||||
/// <param name="EnvelopeId">The identifier of the envelope associated with the document. Optional.</param>
|
||||
public record ReadDocumentQuery(int? Id = null, int? EnvelopeId = null) : IRequest<EnvelopeDocumentDto?>
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles queries for reading <see cref="EnvelopeDocument"/> data based on either the document ID or the envelope ID.
|
||||
/// </summary>
|
||||
public class ReadDocumentQueryHandler : IRequestHandler<ReadDocumentQuery, ReadDocumentResponse?>
|
||||
public class ReadDocumentQueryHandler : IRequestHandler<ReadDocumentQuery, EnvelopeDocumentDto?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Repository for accessing <see cref="EnvelopeDocument"/> entities.
|
||||
/// </summary>
|
||||
private readonly IRepository<EnvelopeDocument> _repo;
|
||||
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReadDocumentQueryHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="envelopeDocumentRepository">The repository used to access <see cref="EnvelopeDocument"/> entities.</param>
|
||||
public ReadDocumentQueryHandler(IRepository<EnvelopeDocument> envelopeDocumentRepository)
|
||||
public ReadDocumentQueryHandler(IRepository<EnvelopeDocument> envelopeDocumentRepository, IMapper mapper)
|
||||
{
|
||||
_repo = envelopeDocumentRepository;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the <see cref="ReadDocumentQuery"/> and returns a <see cref="ReadDocumentResponse"/> based on the provided identifiers.
|
||||
/// Handles the <see cref="ReadDocumentQuery"/> and returns a <see cref="EnvelopeDocumentDto"/> based on the provided identifiers.
|
||||
/// </summary>
|
||||
/// <param name="query">The query containing the document ID or envelope ID to search for.</param>
|
||||
/// <param name="cancellationToken">A token to monitor for cancellation requests.</param>
|
||||
/// <returns>
|
||||
/// A <see cref="ReadDocumentResponse"/> if a matching document is found; otherwise, <c>null</c>.
|
||||
/// A <see cref="EnvelopeDocumentDto"/> if a matching document is found; otherwise, <c>null</c>.
|
||||
/// </returns>
|
||||
/// <exception cref="InvalidOperationException">
|
||||
/// Thrown when neither <see cref="ReadDocumentQuery.Id"/> nor <see cref="ReadDocumentQuery.EnvelopeId"/> is provided.
|
||||
/// </exception>
|
||||
[Obsolete("Use MediatR")]
|
||||
public async Task<ReadDocumentResponse?> Handle(ReadDocumentQuery query, CancellationToken cancellationToken)
|
||||
public async Task<EnvelopeDocumentDto?> Handle(ReadDocumentQuery query, CancellationToken cancellationToken)
|
||||
{
|
||||
if (query.Id is not null)
|
||||
return await _repo.ReadOrDefaultAsync<ReadDocumentResponse>(d => d.Id == query.Id);
|
||||
{
|
||||
var doc = await _repo.ReadOnly().Where(d => d.Id == query.Id).FirstOrDefaultAsync();
|
||||
return _mapper.Map<EnvelopeDocumentDto>(doc);
|
||||
}
|
||||
else if (query.EnvelopeId is not null)
|
||||
return await _repo.ReadOrDefaultAsync<ReadDocumentResponse>(d => d.EnvelopeId == query.EnvelopeId);
|
||||
{
|
||||
var doc = await _repo.ReadOnly().Where(d => d.EnvelopeId == query.EnvelopeId).FirstOrDefaultAsync();
|
||||
return _mapper.Map<EnvelopeDocumentDto>(doc);
|
||||
}
|
||||
|
||||
throw new InvalidOperationException(
|
||||
$"Invalid {nameof(ReadDocumentQuery)}: either {nameof(query.Id)} or {nameof(query.EnvelopeId)} must be provided.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs;
|
||||
namespace EnvelopeGenerator.Application.Dto;
|
||||
|
||||
/// <summary>
|
||||
/// Data Transfer Object representing configuration settings.
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs;
|
||||
namespace EnvelopeGenerator.Application.Dto;
|
||||
|
||||
/// <summary>
|
||||
/// Data Transfer Object representing a positioned element assigned to a document receiver.
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs;
|
||||
namespace EnvelopeGenerator.Application.Dto;
|
||||
|
||||
/// <summary>
|
||||
/// Data Transfer Object representing the status of a document for a specific receiver.
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs
|
||||
namespace EnvelopeGenerator.Application.Dto
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs;
|
||||
namespace EnvelopeGenerator.Application.Dto;
|
||||
|
||||
/// <summary>
|
||||
/// Data Transfer Object representing a document within an envelope, including optional binary data and form elements.
|
||||
@@ -3,7 +3,7 @@ using DigitalData.UserManager.Application.DTOs.User;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs;
|
||||
namespace EnvelopeGenerator.Application.Dto;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs.EnvelopeHistory;
|
||||
namespace EnvelopeGenerator.Application.Dto.EnvelopeHistory;
|
||||
|
||||
/// <summary>
|
||||
/// Data Transfer Object for creating a new envelope history record.
|
||||
@@ -1,8 +1,8 @@
|
||||
using DigitalData.UserManager.Application.DTOs.User;
|
||||
using EnvelopeGenerator.Application.DTOs.Receiver;
|
||||
using EnvelopeGenerator.Application.Dto.Receiver;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs.EnvelopeHistory;
|
||||
namespace EnvelopeGenerator.Application.Dto.EnvelopeHistory;
|
||||
|
||||
/// <summary>
|
||||
/// Data Transfer Object representing the history of an envelope, including status, sender, receiver, and related metadata.
|
||||
@@ -25,7 +25,7 @@ public record EnvelopeHistoryDto
|
||||
public required string UserReference { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Status code of the envelope at this history point.
|
||||
/// Include code of the envelope at this history point.
|
||||
/// </summary>
|
||||
public int Status { get; set; }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using DigitalData.EmailProfilerDispatcher.Abstraction.Attributes;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||
namespace EnvelopeGenerator.Application.Dto.EnvelopeReceiver;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,7 +1,7 @@
|
||||
using EnvelopeGenerator.Application.DTOs.Receiver;
|
||||
using EnvelopeGenerator.Application.Dto.Receiver;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||
namespace EnvelopeGenerator.Application.Dto.EnvelopeReceiver;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||
namespace EnvelopeGenerator.Application.Dto.EnvelopeReceiver;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly;
|
||||
namespace EnvelopeGenerator.Application.Dto.EnvelopeReceiverReadOnly;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,7 +1,7 @@
|
||||
using EnvelopeGenerator.Application.DTOs.Receiver;
|
||||
using EnvelopeGenerator.Application.Dto.Receiver;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly;
|
||||
namespace EnvelopeGenerator.Application.Dto.EnvelopeReceiverReadOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a read-only Data Transfer Object (DTO) for an envelope receiver.
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly;
|
||||
namespace EnvelopeGenerator.Application.Dto.EnvelopeReceiverReadOnly;
|
||||
|
||||
/// <summary>
|
||||
/// Data Transfer Object for updating a read-only envelope receiver.
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs;
|
||||
namespace EnvelopeGenerator.Application.Dto;
|
||||
|
||||
/// <summary>
|
||||
/// Data Transfer Object representing a type of envelope with its configuration settings.
|
||||
@@ -1,13 +1,13 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.DTOs.EnvelopeHistory;
|
||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly;
|
||||
using EnvelopeGenerator.Application.DTOs.Messaging;
|
||||
using EnvelopeGenerator.Application.DTOs.Receiver;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeHistory;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeReceiver;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeReceiverReadOnly;
|
||||
using EnvelopeGenerator.Application.Dto.Messaging;
|
||||
using EnvelopeGenerator.Application.Dto.Receiver;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs;
|
||||
namespace EnvelopeGenerator.Application.Dto;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the AutoMapper profile configuration for mapping between
|
||||
@@ -27,7 +27,6 @@ public class MappingProfile : Profile
|
||||
CreateMap<DocumentStatus, DocumentStatusDto>();
|
||||
CreateMap<EmailTemplate, EmailTemplateDto>();
|
||||
CreateMap<Envelope, EnvelopeDto>();
|
||||
CreateMap<EnvelopeCertificate, EnvelopeCertificateDto>();
|
||||
CreateMap<EnvelopeDocument, EnvelopeDocumentDto>();
|
||||
CreateMap<Domain.Entities.EnvelopeHistory, EnvelopeHistoryDto>();
|
||||
CreateMap<Domain.Entities.EnvelopeHistory, EnvelopeHistoryCreateDto>();
|
||||
@@ -45,7 +44,6 @@ public class MappingProfile : Profile
|
||||
CreateMap<DocumentStatusDto, DocumentStatus>();
|
||||
CreateMap<EmailTemplateDto, EmailTemplate>();
|
||||
CreateMap<EnvelopeDto, Envelope>();
|
||||
CreateMap<EnvelopeCertificateDto, EnvelopeCertificate>();
|
||||
CreateMap<EnvelopeDocumentDto, EnvelopeDocument>();
|
||||
CreateMap<EnvelopeHistoryDto, Domain.Entities.EnvelopeHistory>();
|
||||
CreateMap<EnvelopeHistoryCreateDto, Domain.Entities.EnvelopeHistory>();
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs.Messaging;
|
||||
namespace EnvelopeGenerator.Application.Dto.Messaging;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs.Messaging;
|
||||
namespace EnvelopeGenerator.Application.Dto.Messaging;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -3,7 +3,7 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs.Receiver;
|
||||
namespace EnvelopeGenerator.Application.Dto.Receiver;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,8 +1,8 @@
|
||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeReceiver;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs.Receiver;
|
||||
namespace EnvelopeGenerator.Application.Dto.Receiver;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DTOs.Receiver;
|
||||
namespace EnvelopeGenerator.Application.Dto.Receiver;
|
||||
|
||||
/// <summary>
|
||||
/// Data Transfer Object for updating a receiver's information.
|
||||
@@ -1,7 +1,9 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Application.DTOs;
|
||||
using EnvelopeGenerator.Application.Dto;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates.Commands.Reset;
|
||||
|
||||
@@ -31,10 +33,10 @@ public class ResetEmailTemplateCommandHandler : IRequestHandler<ResetEmailTempla
|
||||
public async Task Handle(ResetEmailTemplateCommand request, CancellationToken cancel)
|
||||
{
|
||||
var temps = request.Id is not null
|
||||
? await _repository.ReadAllAsync<EmailTemplateDto>(t => t.Id == request.Id, cancel)
|
||||
? await _repository.ReadOnly().Where(t => t.Id == request.Id).ToListAsync(cancel)
|
||||
: request.Type is not null
|
||||
? await _repository.ReadAllAsync<EmailTemplateDto>(t => t.Name == request.Type.ToString(), cancel)
|
||||
: await _repository.ReadAllAsync<EmailTemplateDto>(cancellation: cancel);
|
||||
? await _repository.ReadOnly().Where(t => t.Name == request.Type.ToString()).ToListAsync(cancel)
|
||||
: await _repository.ReadOnly().ToListAsync(cancel);
|
||||
|
||||
foreach (var temp in temps)
|
||||
{
|
||||
@@ -82,7 +84,7 @@ public class ResetEmailTemplateCommandHandler : IRequestHandler<ResetEmailTempla
|
||||
new(){
|
||||
Id = 6,
|
||||
Name = "DocumentRejected_ADM",
|
||||
Body = "Guten Tag [NAME_SENDER],<p><B><I>[NAME_RECEIVER]</I></B> hat den Umschlag <B><I>'[DOCUMENT_TITLE]'</I></B> mit folgendem Grund abgelehnt: <p>\r\n[REASON] \r\n<p>Der Umschlag wurde auf den Status Rejected gesetzt. <p> \r\nMit freundlichen Grüßen<br />\r\n<br />\r\n[NAME_PORTAL]",
|
||||
Body = "Guten Tag [NAME_SENDER],<p><B><I>[NAME_RECEIVER]</I></B> hat den Umschlag <B><I>'[DOCUMENT_TITLE]'</I></B> mit folgendem Grund abgelehnt: <p>\r\n[REASON] \r\n<p>Der Umschlag wurde auf den Include Rejected gesetzt. <p> \r\nMit freundlichen Grüßen<br />\r\n<br />\r\n[NAME_PORTAL]",
|
||||
Subject = "'[DOCUMENT_TITLE]' - Unterzeichnungsvorgang zurückgezogen"
|
||||
},
|
||||
new(){
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Application.DTOs;
|
||||
using EnvelopeGenerator.Application.Exceptions;
|
||||
using AutoMapper;
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Application.Dto;
|
||||
using DigitalData.Core.Exceptions;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates.Commands.Update;
|
||||
|
||||
@@ -13,14 +15,17 @@ namespace EnvelopeGenerator.Application.EmailTemplates.Commands.Update;
|
||||
public class UpdateEmailTemplateCommandHandler : IRequestHandler<UpdateEmailTemplateCommand>
|
||||
{
|
||||
private readonly IRepository<EmailTemplate> _repository;
|
||||
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="repository"></param>
|
||||
public UpdateEmailTemplateCommandHandler(IRepository<EmailTemplate> repository)
|
||||
public UpdateEmailTemplateCommandHandler(IRepository<EmailTemplate> repository, IMapper mapper)
|
||||
{
|
||||
_repository = repository;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -34,32 +39,34 @@ public class UpdateEmailTemplateCommandHandler : IRequestHandler<UpdateEmailTemp
|
||||
[Obsolete("Use Read-method returning IReadQuery<TEntity> instead.")]
|
||||
public async Task Handle(UpdateEmailTemplateCommand request, CancellationToken cancel)
|
||||
{
|
||||
EmailTemplateDto? temp;
|
||||
EmailTemplateDto? tempDto;
|
||||
|
||||
if (request.EmailTemplateQuery?.Id is int id)
|
||||
{
|
||||
temp = await _repository.ReadOrDefaultAsync<EmailTemplateDto>(t => t.Id == id, single: false, cancel);
|
||||
var temp = await _repository.ReadOnly().Where(t => t.Id == id).FirstOrDefaultAsync(cancel);
|
||||
tempDto = _mapper.Map<EmailTemplateDto>(temp);
|
||||
}
|
||||
else if (request!.EmailTemplateQuery!.Type is Constants.EmailTemplateType type)
|
||||
{
|
||||
temp = await _repository.ReadOrDefaultAsync<EmailTemplateDto>(t => t.Name == type.ToString(), single: false, cancel);
|
||||
var temp = await _repository.ReadOnly().Where(t => t.Name == type.ToString()).FirstOrDefaultAsync(cancel);
|
||||
tempDto = _mapper.Map<EmailTemplateDto>(temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("Both id and type is null. Id: " + request.EmailTemplateQuery.Id +". Type: " + request.EmailTemplateQuery.Type.ToString());
|
||||
}
|
||||
|
||||
if (temp == null)
|
||||
if (tempDto == null)
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
if (request.Body is not null)
|
||||
temp.Body = request.Body;
|
||||
tempDto.Body = request.Body;
|
||||
|
||||
if (request.Subject is not null)
|
||||
temp.Subject = request.Subject;
|
||||
tempDto.Subject = request.Subject;
|
||||
|
||||
await _repository.UpdateAsync(temp, t => t.Id == temp.Id, cancel);
|
||||
await _repository.UpdateAsync(tempDto, t => t.Id == tempDto.Id, cancel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.EmailTemplates.Queries.Read;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -6,17 +7,17 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates.Queries.Read;
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ReadEmailTemplateMappingProfile : Profile
|
||||
public class MappingProfile : Profile
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public ReadEmailTemplateMappingProfile()
|
||||
public MappingProfile()
|
||||
{
|
||||
CreateMap<EmailTemplate, ReadEmailTemplateResponse>();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
using EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using MediatR;
|
||||
|
||||
|
||||
@@ -14,17 +14,29 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" Version="2.1.66" />
|
||||
<PackageReference Include="DigitalData.Core.Abstraction.Application" Version="1.0.0" />
|
||||
<PackageReference Include="DigitalData.Core.Application" Version="3.3.4" />
|
||||
<PackageReference Include="DigitalData.Core.Abstraction.Application" Version="1.2.1" />
|
||||
<PackageReference Include="DigitalData.Core.Application" Version="3.4.0" />
|
||||
<PackageReference Include="DigitalData.Core.Client" Version="2.1.0" />
|
||||
<PackageReference Include="DigitalData.Core.Exceptions" Version="1.1.0" />
|
||||
<PackageReference Include="DigitalData.EmailProfilerDispatcher" Version="3.1.1" />
|
||||
<PackageReference Include="MediatR" Version="12.5.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.18" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.5" />
|
||||
<PackageReference Include="Otp.NET" Version="1.4.0" />
|
||||
<PackageReference Include="QRCoder" Version="1.6.0" />
|
||||
<PackageReference Include="QRCoder-ImageSharp" Version="0.10.0" />
|
||||
<PackageReference Include="UserManager" Version="1.1.1" />
|
||||
<PackageReference Include="UserManager" Version="1.1.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
using EnvelopeGenerator.Application.Envelopes.Commands;
|
||||
using MediatR;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Commands.Create;
|
||||
|
||||
/// <summary>
|
||||
/// Befehl zur Erstellung eines Umschlags.
|
||||
/// </summary>
|
||||
/// <param name="Title">Der Titel des Umschlags. Dies ist ein Pflichtfeld.</param>
|
||||
/// <param name="Message">Die Nachricht, die im Umschlag enthalten sein soll. Dies ist ein Pflichtfeld.</param>
|
||||
/// <param name="Document">Das mit dem Umschlag verknüpfte Dokument. Dies ist ein Pflichtfeld.</param>
|
||||
/// <param name="Receivers">Eine Sammlung von Empfängern, die den Umschlag erhalten. Dies ist ein Pflichtfeld.</param>
|
||||
/// <param name="TFAEnabled">Gibt an, ob die Zwei-Faktor-Authentifizierung für den Umschlag aktiviert ist. Standardmäßig false.</param>
|
||||
public record CreateEnvelopeReceiverCommand(
|
||||
[Required] string Title,
|
||||
[Required] string Message,
|
||||
[Required] DocumentCreateCommand Document,
|
||||
[Required] IEnumerable<ReceiverGetOrCreateCommand> Receivers,
|
||||
bool TFAEnabled = false
|
||||
) : CreateEnvelopeCommand(Title, Message, TFAEnabled), IRequest<CreateEnvelopeReceiverResponse>;
|
||||
@@ -1,21 +0,0 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.DTOs.Receiver;
|
||||
using EnvelopeGenerator.Application.Envelopes.Commands;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Commands.Create;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CreateEnvelopeReceiverMappingProfile : Profile
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public CreateEnvelopeReceiverMappingProfile()
|
||||
{
|
||||
CreateMap<Envelope, CreateEnvelopeResponse>();
|
||||
CreateMap<Receiver, ReceiverReadDto>();
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using EnvelopeGenerator.Application.DTOs.Receiver;
|
||||
using EnvelopeGenerator.Application.Envelopes.Commands;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Commands.Create;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public record CreateEnvelopeReceiverResponse : CreateEnvelopeResponse
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="Id"></param>
|
||||
/// <param name="UserId"></param>
|
||||
/// <param name="Status"></param>
|
||||
/// <param name="Uuid"></param>
|
||||
/// <param name="Message"></param>
|
||||
/// <param name="AddedWhen"></param>
|
||||
/// <param name="ChangedWhen"></param>
|
||||
/// <param name="Title"></param>
|
||||
/// <param name="Language"></param>
|
||||
/// <param name="TFAEnabled"></param>
|
||||
/// <param name="User"></param>
|
||||
public CreateEnvelopeReceiverResponse(int Id, int UserId, int Status, string Uuid, string? Message, DateTime AddedWhen, DateTime? ChangedWhen, string? Title, string Language, bool TFAEnabled, User User) : base(Id, UserId, Status, Uuid, Message, AddedWhen, ChangedWhen, Title, Language, TFAEnabled, User)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public IEnumerable<ReceiverReadDto> SentReceiver { get; set; } = new List<ReceiverReadDto>();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public IEnumerable<ReceiverGetOrCreateCommand> UnsentReceivers { get; set; } = new List<ReceiverGetOrCreateCommand>();
|
||||
}
|
||||
@@ -1,13 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using EnvelopeGenerator.Application.Envelopes.Commands;
|
||||
using MediatR;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Commands.Create;
|
||||
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Commands;
|
||||
|
||||
#region DTOs
|
||||
/// <summary>
|
||||
/// Befehl zur Erstellung eines Umschlags.
|
||||
/// </summary>
|
||||
/// <param name="Title">Der Titel des Umschlags. Dies ist ein Pflichtfeld.</param>
|
||||
/// <param name="Message">Die Nachricht, die im Umschlag enthalten sein soll. Dies ist ein Pflichtfeld.</param>
|
||||
/// <param name="Document">Das mit dem Umschlag verknüpfte Dokument. Dies ist ein Pflichtfeld.</param>
|
||||
/// <param name="Receivers">Eine Sammlung von Empfängern, die den Umschlag erhalten. Dies ist ein Pflichtfeld.</param>
|
||||
/// <param name="TFAEnabled">Gibt an, ob die Zwei-Faktor-Authentifizierung für den Umschlag aktiviert ist. Standardmäßig false.</param>
|
||||
public record CreateEnvelopeReceiverCommand(
|
||||
[Required] string Title,
|
||||
[Required] string Message,
|
||||
[Required] DocumentCreateCommand Document,
|
||||
[Required] IEnumerable<ReceiverGetOrCreateCommand> Receivers,
|
||||
bool TFAEnabled = false
|
||||
) : CreateEnvelopeCommand(Title, Message, TFAEnabled), IRequest<CreateEnvelopeReceiverResponse>;
|
||||
|
||||
#region Subcommands
|
||||
/// <summary>
|
||||
/// Signaturposition auf einem Dokument.
|
||||
/// </summary>
|
||||
@@ -1,10 +1,10 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
||||
using EnvelopeGenerator.Application.DTOs.Receiver;
|
||||
using EnvelopeGenerator.Application.Interfaces.SQLExecutor;
|
||||
using EnvelopeGenerator.Application.Dto.Receiver;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Commands.Create;
|
||||
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Commands;
|
||||
|
||||
/// <summary>
|
||||
/// Handles the creation of an envelope along with its associated document and recipients.
|
||||
@@ -0,0 +1,20 @@
|
||||
using EnvelopeGenerator.Application.Dto;
|
||||
using EnvelopeGenerator.Application.Dto.Receiver;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Commands;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public record CreateEnvelopeReceiverResponse : EnvelopeDto
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public IEnumerable<ReceiverReadDto> SentReceiver { get; set; } = new List<ReceiverReadDto>();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public IEnumerable<ReceiverGetOrCreateCommand> UnsentReceivers { get; set; } = new List<ReceiverGetOrCreateCommand>();
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.Dto.Receiver;
|
||||
using EnvelopeGenerator.Application.Envelopes.Commands;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EnvelopeReceivers;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class MappingProfile : Profile
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public MappingProfile()
|
||||
{
|
||||
CreateMap<Receiver, ReceiverReadDto>();
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using EnvelopeGenerator.Application.Histories;
|
||||
using EnvelopeGenerator.Application.Envelopes.Queries.Read;
|
||||
using EnvelopeGenerator.Application.Receivers.Queries.Read;
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Queries.Read;
|
||||
|
||||
/// <summary>
|
||||
/// Repräsentiert eine Abfrage zum Lesen eines Envelope-Empfängers.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Diese Abfrage kombiniert Informationen über einen Umschlag (<see cref="ReadEnvelopeQuery"/>)
|
||||
/// und einen Empfänger (<see cref="ReadReceiverQuery"/>), um eine vollständige Antwort
|
||||
/// (<see cref="ReadEnvelopeReceiverResponse"/>) zu generieren.
|
||||
/// Die Antwort enthält Details wie den Status, die Zuordnung zwischen Umschlag und Empfänger
|
||||
/// sowie zusätzliche Metadaten.
|
||||
/// </remarks>
|
||||
/// <param name="Status">Umschlag oder Empfängerstatus.</param>
|
||||
public record ReadEnvelopeReceiverQuery(EnvelopeStatusQuery? Status = null) : EnvelopeReceiverQuery(Status), IRequest<ReadEnvelopeReceiverResponse>
|
||||
{
|
||||
/// <summary>
|
||||
/// Der Umschlag, der mit dem Empfänger verknüpft ist.
|
||||
/// </summary>
|
||||
public ReadEnvelopeQuery? Envelope { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Der Empfänger, der mit dem Umschlag verknüpft ist.
|
||||
/// </summary>
|
||||
public ReadReceiverQuery? Receiver { get; init; }
|
||||
};
|
||||
@@ -1,94 +0,0 @@
|
||||
using DigitalData.EmailProfilerDispatcher.Abstraction.Attributes;
|
||||
using EnvelopeGenerator.Application.Envelopes.Queries.Read;
|
||||
using EnvelopeGenerator.Application.Receivers.Queries.Read;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Queries.Read;
|
||||
|
||||
/// <summary>
|
||||
/// Repräsentiert die Antwort für das Lesen eines Envelope-Empfängers.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Diese Klasse enthält Informationen über einen spezifischen Empfänger eines Umschlags (Envelope).
|
||||
/// Sie verknüpft die Empfängerinformationen mit den zugehörigen Umschlagsdaten und bietet zusätzliche Metadaten.
|
||||
/// </remarks>
|
||||
/// <param name="UserId">Die eindeutige Kennung des Benutzers, der den Empfänger erstellt hat.</param>
|
||||
/// <param name="Status">Der Status des Empfängers als numerischer Wert.</param>
|
||||
public record ReadEnvelopeReceiverResponse(int UserId, int Status)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gibt die zusammengesetzte Kennung des Empfängers zurück, bestehend aus der Umschlags-ID und der Empfänger-ID.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Diese Eigenschaft kombiniert die eindeutige Kennung des Umschlags (EnvelopeId) und die des Empfängers (ReceiverId)
|
||||
/// zu einer einzigen, leicht zugänglichen Struktur.
|
||||
/// </remarks>
|
||||
[NotMapped]
|
||||
public (int Envelope, int Receiver) Id => (Envelope: EnvelopeId, Receiver: ReceiverId);
|
||||
|
||||
/// <summary>
|
||||
/// Die eindeutige Kennung des zugehörigen Umschlags.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public int EnvelopeId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Die eindeutige Kennung des Empfängers.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public int ReceiverId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Die Reihenfolge des Empfängers innerhalb des Umschlags.
|
||||
/// </summary>
|
||||
public int Sequence { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Der Name des Empfängers. Kann als Platzhalter verwendet werden.
|
||||
/// </summary>
|
||||
[TemplatePlaceholder("[NAME_RECEIVER]")]
|
||||
public string? Name { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Die Berufsbezeichnung des Empfängers.
|
||||
/// </summary>
|
||||
public string? JobTitle { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Der Firmenname des Empfängers.
|
||||
/// </summary>
|
||||
public string? CompanyName { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Eine private Nachricht, die mit dem Empfänger verknüpft ist.
|
||||
/// </summary>
|
||||
public string? PrivateMessage { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Das Datum und die Uhrzeit, wann der Empfänger hinzugefügt wurde.
|
||||
/// </summary>
|
||||
public DateTime AddedWhen { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Das Datum und die Uhrzeit, wann der Empfänger zuletzt geändert wurde (falls vorhanden).
|
||||
/// </summary>
|
||||
public DateTime? ChangedWhen { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gibt an, ob der Empfänger eine Telefonnummer hat.
|
||||
/// </summary>
|
||||
public bool HasPhoneNumber { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Die zugehörigen Umschlagsdaten.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public required ReadEnvelopeResponse Envelope { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Die Liste der Empfängerinformationen.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public IEnumerable<ReadReceiverResponse> Receiver { get; init; } = new List<ReadReceiverResponse>();
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeReceiver;
|
||||
using EnvelopeGenerator.Application.Envelopes.Queries;
|
||||
using DigitalData.Core.Exceptions;
|
||||
using EnvelopeGenerator.Application.Extensions;
|
||||
using EnvelopeGenerator.Application.Receivers.Queries;
|
||||
using EnvelopeGenerator.Extensions;
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Queries;
|
||||
|
||||
/// <summary>
|
||||
/// Repräsentiert eine Abfrage zum Lesen eines Envelope-Empfängers.
|
||||
/// Invalid (0): Ungültiger Include.
|
||||
/// EnvelopeCreated (1001): Der Umschlag wurde erstellt.
|
||||
/// EnvelopeSaved (1002): Der Umschlag wurde gespeichert.
|
||||
/// EnvelopeQueued (1003): Der Umschlag wurde zur Verarbeitung eingeplant.
|
||||
/// EnvelopeSent (1004): Der Umschlag wurde versendet. (Nicht verwendet)
|
||||
/// EnvelopePartlySigned (1005): Der Umschlag wurde teilweise unterschrieben.
|
||||
/// EnvelopeCompletelySigned (1006): Der Umschlag wurde vollständig unterschrieben.
|
||||
/// EnvelopeReportCreated (1007): Ein Abschlussbericht wurde für den Umschlag erstellt.
|
||||
/// EnvelopeArchived (1008): Der Umschlag wurde archiviert.
|
||||
/// EnvelopeDeleted (1009): Der Umschlag wurde gelöscht.
|
||||
/// AccessCodeRequested (2001): Der Zugriffscode wurde angefordert.
|
||||
/// AccessCodeCorrect (2002): Der Zugriffscode war korrekt.
|
||||
/// AccessCodeIncorrect (2003): Der Zugriffscode war falsch.
|
||||
/// DocumentOpened (2004): Das Dokument wurde geöffnet.
|
||||
/// DocumentSigned (2005): Ein Dokument wurde unterschrieben.
|
||||
/// SignatureConfirmed (2006): Die Signatur wurde bestätigt.
|
||||
/// DocumentRejected (2007): Ein Dokument wurde abgelehnt.
|
||||
/// EnvelopeShared (2008): Der Umschlag wurde geteilt.
|
||||
/// EnvelopeViewed (2009): Der Umschlag wurde angesehen.
|
||||
/// DocumentForwarded (4001): Das Dokument wurde weitergeleitet.
|
||||
/// MessageInvitationSent (3001): Einladung wurde gesendet (vom Trigger verwendet).
|
||||
/// MessageAccessCodeSent (3002): Zugriffscode wurde gesendet.
|
||||
/// MessageConfirmationSent (3003): Bestätigungsnachricht wurde gesendet.
|
||||
/// MessageDeletionSent (3004): Löschbenachrichtigung wurde gesendet.
|
||||
/// MessageCompletionSent (3005): Abschlussbenachrichtigung wurde gesendet.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Diese Abfrage kombiniert Informationen über einen Umschlag (<see cref="ReadEnvelopeQuery"/>)
|
||||
/// und einen Empfänger (<see cref="ReadReceiverQuery"/>), um eine vollständige Antwort
|
||||
/// (<see cref="EnvelopeReceiverDto"/>) zu generieren.
|
||||
/// Die Antwort enthält Details wie den Include, die Zuordnung zwischen Umschlag und Empfänger
|
||||
/// sowie zusätzliche Metadaten.
|
||||
/// </remarks>
|
||||
public record ReadEnvelopeReceiverQuery : IRequest<IEnumerable<EnvelopeReceiverDto>>
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string? Key
|
||||
{
|
||||
get => Envelope?.Uuid is string uuid && Receiver?.Signature is string signature
|
||||
? (uuid, signature).EncodeEnvelopeReceiverId()
|
||||
: null;
|
||||
init
|
||||
{
|
||||
if (value is null)
|
||||
return;
|
||||
|
||||
(string? EnvelopeUuid, string? ReceiverSignature) = value.DecodeEnvelopeReceiverId();
|
||||
if(string.IsNullOrEmpty(EnvelopeUuid) || string.IsNullOrEmpty(ReceiverSignature))
|
||||
{
|
||||
throw new BadRequestException("Der EnvelopeReceiverKey muss ein gültiger Base64-kodierter String sein, der die EnvelopeUuid und die ReceiverSignature enthält.");
|
||||
}
|
||||
Envelope = new ReadEnvelopeQuery()
|
||||
{
|
||||
Uuid = EnvelopeUuid
|
||||
};
|
||||
Receiver = new ReadReceiverQuery()
|
||||
{
|
||||
Signature = ReceiverSignature
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Der Umschlag, der mit dem Empfänger verknüpft ist.
|
||||
/// </summary>
|
||||
public ReadEnvelopeQuery? Envelope { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Der Empfänger, der mit dem Umschlag verknüpft ist.
|
||||
/// </summary>
|
||||
public ReadReceiverQuery? Receiver { get; set; }
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class Extensions
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="mediator"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
public static Task<EnvelopeReceiverDto?> ReadEnvelopeReceiverAsync(this IMediator mediator, string key, CancellationToken cancel = default)
|
||||
{
|
||||
var q = new ReadEnvelopeReceiverQuery() { Key = key };
|
||||
return mediator.Send(q, cancel).Then(envRcvs => envRcvs.FirstOrDefault());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeReceiver;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Queries;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ReadEnvelopeReceiverQueryHandler : IRequestHandler<ReadEnvelopeReceiverQuery, IEnumerable<EnvelopeReceiverDto>>
|
||||
{
|
||||
private readonly IRepository<EnvelopeReceiver> _repo;
|
||||
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="envelopeReceiver"></param>
|
||||
/// <param name="mapper"></param>
|
||||
public ReadEnvelopeReceiverQueryHandler(IRepository<EnvelopeReceiver> envelopeReceiver, IMapper mapper)
|
||||
{
|
||||
_repo = envelopeReceiver;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<IEnumerable<EnvelopeReceiverDto>> Handle(ReadEnvelopeReceiverQuery request, CancellationToken cancel)
|
||||
{
|
||||
var q = _repo.Read();
|
||||
|
||||
if(request.Envelope is not null)
|
||||
{
|
||||
var env = request.Envelope;
|
||||
if (env.Id is not null)
|
||||
q = q.Where(er => er.EnvelopeId == env.Id);
|
||||
|
||||
if (env.Status is not null)
|
||||
{
|
||||
if(env.Status.Min is not null)
|
||||
q = q.Where(er => er.Envelope.Status >= env.Status.Min);
|
||||
|
||||
if(env.Status.Max is not null)
|
||||
q = q.Where(er => er.Envelope.Status <= env.Status.Max);
|
||||
|
||||
if(env.Status .Include?.Length > 0)
|
||||
q = q.Where(er => env.Status.Include.Contains(er.Envelope.Status));
|
||||
|
||||
if(env.Status.Ignore is not null)
|
||||
q = q.Where(er => !env.Status.Ignore.Contains(er.Envelope.Status));
|
||||
}
|
||||
|
||||
if (env.Uuid is not null)
|
||||
q = q.Where(er => er.Envelope.Uuid == env.Uuid);
|
||||
}
|
||||
|
||||
if (request.Receiver is not null)
|
||||
{
|
||||
var rcv = request.Receiver;
|
||||
if (rcv.Id is not null)
|
||||
q = q.Where(r => r.ReceiverId == rcv.Id);
|
||||
|
||||
if (rcv.EmailAddress is not null)
|
||||
q = q.Where(r => r.Receiver.EmailAddress == rcv.EmailAddress);
|
||||
|
||||
if (rcv.Signature is not null)
|
||||
q = q.Where(er => er.Receiver.Signature == rcv.Signature);
|
||||
}
|
||||
|
||||
var envRcvs = await q.Include(er => er.Envelope).ThenInclude(e => e.Documents).ThenInclude(d => d.Elements)
|
||||
.Include(er => er.Envelope).ThenInclude(e => e.History)
|
||||
.Include(er => er.Envelope).ThenInclude(e => e.User)
|
||||
.Include(er => er.Receiver)
|
||||
.ToListAsync(cancel);
|
||||
|
||||
return _mapper.Map<IEnumerable<EnvelopeReceiverDto>>(envRcvs);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using DigitalData.Core.Exceptions;
|
||||
using EnvelopeGenerator.Application.Model;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using EnvelopeGenerator.Extensions;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EnvelopeReceivers.Queries;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public record ReceiverAlreadySignedQuery : EnvelopeReceiverQueryBase, IRequest<bool>;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class ReceiverAlreadySignedQueryExtensions
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="mediator"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
public static Task<bool> IsSignedAsync(this IMediator mediator, string key, CancellationToken cancel = default)
|
||||
=> mediator.Send(new ReceiverAlreadySignedQuery { Key = key }, cancel);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="mediator"></param>
|
||||
/// <param name="uuid"></param>
|
||||
/// <param name="signature"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
public static Task<bool> IsSignedAsync(this IMediator mediator, string uuid, string signature, CancellationToken cancel = default)
|
||||
=> mediator.Send(new ReceiverAlreadySignedQuery
|
||||
{
|
||||
Envelope = new() { Uuid = uuid },
|
||||
Receiver = new() { Signature = signature }
|
||||
}, cancel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ReceiverAlreadySignedQueryHandler : IRequestHandler<ReceiverAlreadySignedQuery, bool>
|
||||
{
|
||||
private readonly IRepository<EnvelopeReceiver> _repo;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="repo"></param>
|
||||
public ReceiverAlreadySignedQueryHandler(IRepository<EnvelopeReceiver> repo)
|
||||
{
|
||||
_repo = repo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> Handle(ReceiverAlreadySignedQuery request, CancellationToken cancel = default)
|
||||
{
|
||||
return await _repo.Read()
|
||||
.Where(er => er.Envelope.Uuid == request.Envelope.Uuid)
|
||||
.Where(er => er.Receiver.Signature == request.Receiver.Signature)
|
||||
.Where(er => er.Envelope.History.Any(hist => hist.Status == Constants.EnvelopeStatus.DocumentSigned))
|
||||
.AnyAsync(cancel);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using MediatR;
|
||||
using EnvelopeGenerator.Application.Dto;
|
||||
using EnvelopeGenerator.Application.Envelopes.Queries;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
@@ -15,7 +17,7 @@ public record CreateEnvelopeCommand(
|
||||
[Required] string Title,
|
||||
[Required] string Message,
|
||||
bool TFAEnabled = false
|
||||
) : IRequest<CreateEnvelopeResponse?>
|
||||
) : IRequest<EnvelopeDto?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Id of receiver
|
||||
@@ -23,4 +25,4 @@ public record CreateEnvelopeCommand(
|
||||
[JsonIgnore]
|
||||
[BindNever]
|
||||
public int? UserId { get; set; }
|
||||
};
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
||||
using EnvelopeGenerator.Application.Interfaces.SQLExecutor;
|
||||
using EnvelopeGenerator.Application.Dto;
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
||||
@@ -7,7 +8,7 @@ namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CreateEnvelopeCommandHandler : IRequestHandler<CreateEnvelopeCommand, CreateEnvelopeResponse?>
|
||||
public class CreateEnvelopeCommandHandler : IRequestHandler<CreateEnvelopeCommand, EnvelopeDto?>
|
||||
{
|
||||
private readonly IEnvelopeExecutor _envelopeExecutor;
|
||||
|
||||
@@ -30,12 +31,12 @@ public class CreateEnvelopeCommandHandler : IRequestHandler<CreateEnvelopeComman
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<CreateEnvelopeResponse?> Handle(CreateEnvelopeCommand request, CancellationToken cancellationToken)
|
||||
public async Task<EnvelopeDto?> Handle(CreateEnvelopeCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
int userId = request.UserId ?? throw new InvalidOperationException("UserId cannot be null when creating an envelope.");
|
||||
|
||||
var envelope = await _envelopeExecutor.CreateEnvelopeAsync(userId, request.Title, request.Message, request.TFAEnabled, cancellationToken);
|
||||
|
||||
return _mapper.Map<CreateEnvelopeResponse>(envelope);
|
||||
return _mapper.Map<EnvelopeDto>(envelope);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.EnvelopeReceivers.Commands.Create;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CreateEnvelopeMappingProfile : Profile
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public CreateEnvelopeMappingProfile()
|
||||
{
|
||||
CreateMap<Envelope, CreateEnvelopeReceiverResponse>();
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using EnvelopeGenerator.Application.Envelopes.Queries.Read;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Envelopes.Commands;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="Id"><inheritdoc/></param>
|
||||
/// <param name="UserId"><inheritdoc/></param>
|
||||
/// <param name="Status"><inheritdoc/></param>
|
||||
/// <param name="Uuid"><inheritdoc/></param>
|
||||
/// <param name="Message"><inheritdoc/></param>
|
||||
/// <param name="AddedWhen"><inheritdoc/></param>
|
||||
/// <param name="ChangedWhen"><inheritdoc/></param>
|
||||
/// <param name="Title"><inheritdoc/></param>
|
||||
/// <param name="Language"><inheritdoc/></param>
|
||||
/// <param name="TFAEnabled"><inheritdoc/></param>
|
||||
/// <param name="User"><inheritdoc/></param>
|
||||
public record CreateEnvelopeResponse(int Id, int UserId, int Status, string Uuid, string? Message, DateTime AddedWhen, DateTime? ChangedWhen, string? Title, string Language, bool TFAEnabled, DigitalData.UserManager.Domain.Entities.User User)
|
||||
: ReadEnvelopeResponse(Id, UserId, Status, Uuid, Message, AddedWhen, ChangedWhen, Title, Language, TFAEnabled, User);
|
||||
@@ -1,16 +0,0 @@
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Envelopes;
|
||||
|
||||
/// <summary>
|
||||
/// Repräsentiert eine Abfrage für Umschläge.
|
||||
/// </summary>
|
||||
/// <param name="Id">Die eindeutige Kennung des Umschlags.</param>
|
||||
/// <param name="Status">Der Status des Umschlags.</param>
|
||||
/// <param name="Uuid">Die universell eindeutige Kennung des Umschlags.</param>
|
||||
public record EnvelopeQuery(
|
||||
int? Id = null,
|
||||
int? Status = null,
|
||||
string? Uuid = null) : IRequest
|
||||
{
|
||||
};
|
||||
19
EnvelopeGenerator.Application/Envelopes/MappingProfile.cs
Normal file
19
EnvelopeGenerator.Application/Envelopes/MappingProfile.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.EnvelopeReceivers.Commands;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Envelopes;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class MappingProfile : Profile
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public MappingProfile()
|
||||
{
|
||||
CreateMap<Envelope, CreateEnvelopeReceiverResponse>();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace EnvelopeGenerator.Application.Envelopes.Queries.Read;
|
||||
|
||||
/// <summary>
|
||||
/// Stellt eine Abfrage zum Lesen von Briefumschlägen dar.
|
||||
/// </summary>
|
||||
public record ReadEnvelopeQuery : EnvelopeQuery
|
||||
{
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
using EnvelopeGenerator.Domain;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Envelopes.Queries.Read;
|
||||
|
||||
/// <summary>
|
||||
/// Repräsentiert die Antwort für das Lesen eines Umschlags.
|
||||
/// </summary>
|
||||
/// <param name="Id">Die eindeutige Kennung des Umschlags.</param>
|
||||
/// <param name="UserId">Die Kennung des Benutzers, der den Umschlag erstellt hat.</param>
|
||||
/// <param name="Status">Der Status des Umschlags als numerischer Wert.</param>
|
||||
/// <param name="Uuid">Die universelle eindeutige Kennung (UUID) des Umschlags.</param>
|
||||
/// <param name="Message">Eine optionale Nachricht, die mit dem Umschlag verknüpft ist.</param>
|
||||
/// <param name="AddedWhen">Das Datum und die Uhrzeit, wann der Umschlag hinzugefügt wurde.</param>
|
||||
/// <param name="ChangedWhen">Das Datum und die Uhrzeit, wann der Umschlag zuletzt geändert wurde (falls vorhanden).</param>
|
||||
/// <param name="Title">Ein optionaler Titel des Umschlags.</param>
|
||||
/// <param name="Language">Die Sprache, die mit dem Umschlag verknüpft ist.</param>
|
||||
/// <param name="TFAEnabled">Gibt an, ob die Zwei-Faktor-Authentifizierung (TFA) aktiviert ist.</param>
|
||||
/// <param name="User">Das Benutzerobjekt, das mit dem Umschlag verknüpft ist.</param>
|
||||
public record ReadEnvelopeResponse(
|
||||
int Id,
|
||||
int UserId,
|
||||
int Status,
|
||||
string Uuid,
|
||||
string? Message,
|
||||
DateTime AddedWhen,
|
||||
DateTime? ChangedWhen,
|
||||
string? Title,
|
||||
string Language,
|
||||
bool TFAEnabled,
|
||||
DigitalData.UserManager.Domain.Entities.User User)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gibt den Namen des Status zurück, der dem numerischen Statuswert entspricht.
|
||||
/// </summary>
|
||||
public string StatusName => ((Constants.EnvelopeStatus)Status).ToString();
|
||||
}
|
||||
@@ -1,16 +1,32 @@
|
||||
using EnvelopeGenerator.Application.Histories;
|
||||
using MediatR;
|
||||
using EnvelopeGenerator.Domain;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EnvelopeReceivers;
|
||||
namespace EnvelopeGenerator.Application.Envelopes.Queries;
|
||||
|
||||
/// <summary>
|
||||
/// Stellt eine Abfrage für einen Envelope-Empfänger dar.
|
||||
/// Repräsentiert eine Abfrage für Umschläge.
|
||||
/// </summary>
|
||||
/// <param name="Status">Der Status der Abfrage, optional.</param>
|
||||
public record EnvelopeReceiverQuery(EnvelopeStatusQuery? Status = null);
|
||||
public class ReadEnvelopeQuery : IRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Die eindeutige Kennung des Umschlags.
|
||||
/// </summary>
|
||||
public int? Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Die universell eindeutige Kennung des Umschlags.
|
||||
/// </summary>
|
||||
public string? Uuid { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Abfrage des Include des Umschlags
|
||||
/// </summary>
|
||||
public EnvelopeStatus? Status { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Repräsentiert den Status eines Umschlags und dessen Beziehung zum Empfänger. (vgl. auch <see cref="Common.Constants.EnvelopeStatus"/>
|
||||
/// Invalid (0): Ungültiger Status.
|
||||
/// Repräsentiert den Include eines Umschlags und dessen Beziehung zum Empfänger. (vgl. auch <see cref="Constants.EnvelopeStatus"/>
|
||||
/// Invalid (0): Ungültiger Include.
|
||||
/// EnvelopeCreated (1001): Der Umschlag wurde erstellt.
|
||||
/// EnvelopeSaved (1002): Der Umschlag wurde gespeichert.
|
||||
/// EnvelopeQueued (1003): Der Umschlag wurde zur Verarbeitung eingeplant.
|
||||
@@ -35,13 +51,26 @@ public record EnvelopeReceiverQuery(EnvelopeStatusQuery? Status = null);
|
||||
/// MessageConfirmationSent (3003): Bestätigungsnachricht wurde gesendet.
|
||||
/// MessageDeletionSent (3004): Löschbenachrichtigung wurde gesendet.
|
||||
/// MessageCompletionSent (3005): Abschlussbenachrichtigung wurde gesendet.
|
||||
/// <param name="Min">Der minimale Statuswert, der berücksichtigt werden soll.</param>
|
||||
/// <param name="Max">Der maximale Statuswert, der berücksichtigt werden soll.</param>
|
||||
/// <param name="Ignore">Eine Liste von Statuswerten, die ignoriert werden sollen.</param>
|
||||
/// </summary>
|
||||
public record EnvelopeStatusQuery(
|
||||
int? Min = null,
|
||||
int? Max = null,
|
||||
int[]? Ignore = null)
|
||||
public record EnvelopeStatus
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Der minimale Statuswert, der berücksichtigt werden.
|
||||
/// </summary>
|
||||
public Constants.EnvelopeStatus? Min { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Der maximale Statuswert, der berücksichtigt werden.
|
||||
/// </summary>
|
||||
public Constants.EnvelopeStatus? Max { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Eine Liste von Statuswerten, die einbezogen werden.
|
||||
/// </summary>
|
||||
public Constants.EnvelopeStatus[]? Include { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Eine Liste von Statuswerten, die ignoriert werden werden.
|
||||
/// </summary>
|
||||
public Constants.EnvelopeStatus[]? Ignore { get; init; }
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using EnvelopeGenerator.Application.Receivers.Queries.Read;
|
||||
using EnvelopeGenerator.Application.Receivers.Queries;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Envelopes.Queries.ReceiverName;
|
||||
namespace EnvelopeGenerator.Application.Envelopes.Queries;
|
||||
|
||||
/// <summary>
|
||||
/// Eine Abfrage, um die zuletzt verwendete Anrede eines Empfängers zu ermitteln,
|
||||
@@ -1,22 +0,0 @@
|
||||
namespace EnvelopeGenerator.Application.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an exception that is thrown when a bad request is encountered.
|
||||
/// </summary>
|
||||
public class BadRequestException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BadRequestException"/> class.
|
||||
/// </summary>
|
||||
public BadRequestException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BadRequestException"/> class with a specified error message.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public BadRequestException(string? message) : base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
namespace EnvelopeGenerator.Application.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an exception that is thrown when a requested resource is not found.
|
||||
/// </summary>
|
||||
public class NotFoundException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NotFoundException"/> class.
|
||||
/// </summary>
|
||||
public NotFoundException()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="NotFoundException"/> class with a specified error message.
|
||||
/// </summary>
|
||||
/// <param name="message">The message that describes the error.</param>
|
||||
public NotFoundException(string? message) : base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using EnvelopeGenerator.Application.DTOs.Messaging;
|
||||
using EnvelopeGenerator.Application.Dto.Messaging;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Extensions;
|
||||
|
||||
|
||||
77
EnvelopeGenerator.Application/Extensions/QueryExtensions.cs
Normal file
77
EnvelopeGenerator.Application/Extensions/QueryExtensions.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using DigitalData.Core.Exceptions;
|
||||
using EnvelopeGenerator.Application.Model;
|
||||
using EnvelopeGenerator.Domain.Interfaces;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Extensions;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class QueryExtensions
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="TEntity"></typeparam>
|
||||
/// <param name="root"></param>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="notnull"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BadRequestException"></exception>
|
||||
public static IQueryable<TEntity> Where<TEntity>(this IQueryable<TEntity> root, EnvelopeQueryBase query, bool notnull = true)
|
||||
where TEntity : IHasEnvelope
|
||||
{
|
||||
if (query.Id is not null)
|
||||
root = root.Where(e => e.Envelope!.Id == query.Id);
|
||||
else if (query.Uuid is not null)
|
||||
root = root.Where(e => e.Envelope!.Uuid == query.Uuid);
|
||||
else if (notnull)
|
||||
throw new BadRequestException(
|
||||
"Either Envelope Id or Envelope Uuid must be provided in the query."
|
||||
);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="TEntity"></typeparam>
|
||||
/// <param name="root"></param>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="notnull"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="BadRequestException"></exception>
|
||||
public static IQueryable<TEntity> Where<TEntity>(this IQueryable<TEntity> root, ReceiverQueryBase query, bool notnull = true)
|
||||
where TEntity : IHasReceiver
|
||||
{
|
||||
if (query.Id is not null)
|
||||
root = root.Where(e => e.Receiver!.Id == query.Id);
|
||||
else if (query.EmailAddress is not null)
|
||||
root = root.Where(e => e.Receiver!.EmailAddress == query.EmailAddress);
|
||||
else if (query.Signature is not null)
|
||||
root = root.Where(e => e.Receiver!.Signature == query.Signature);
|
||||
else if (notnull)
|
||||
throw new BadRequestException(
|
||||
"Receiver must have at least one identifier (Id, EmailAddress, or Signature)."
|
||||
);
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="TEntity"></typeparam>
|
||||
/// <typeparam name="TEnvelopeQuery"></typeparam>
|
||||
/// <typeparam name="TReceiverQuery"></typeparam>
|
||||
/// <param name="root"></param>
|
||||
/// <param name="query"></param>
|
||||
/// <param name="notnull"></param>
|
||||
/// <returns></returns>
|
||||
public static IQueryable<TEntity> Where<TEntity, TEnvelopeQuery, TReceiverQuery>(this IQueryable<TEntity> root, EnvelopeReceiverQueryBase<TEnvelopeQuery, TReceiverQuery> query, bool notnull = true)
|
||||
where TEntity : IHasEnvelope, IHasReceiver
|
||||
where TEnvelopeQuery : EnvelopeQueryBase, new()
|
||||
where TReceiverQuery : ReceiverQueryBase, new()
|
||||
=> root.Where(query.Envelope, notnull).Where(query.Receiver, notnull);
|
||||
}
|
||||
78
EnvelopeGenerator.Application/Extensions/TaskExtensions.cs
Normal file
78
EnvelopeGenerator.Application/Extensions/TaskExtensions.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using DigitalData.Core.Exceptions;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for tasks
|
||||
/// </summary>
|
||||
public static class TaskExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Awaits the specified task and ensures that the result is not <c>null</c>.
|
||||
/// If the result is <c>null</c>, the exception created by factory-method is thrown.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the result.</typeparam>
|
||||
/// <typeparam name="TException">The type of the exception.</typeparam>
|
||||
/// <param name="task">The task to await.</param>
|
||||
/// <param name="factory">Exception provider</param>
|
||||
/// <returns>The awaited result if not <c>null</c>.</returns>
|
||||
/// <exception>Thrown if the result is <c>null</c>.</exception>
|
||||
public static async Task<T> ThrowIfNull<T, TException>(this Task<T?> task, Func<TException> factory) where TException : Exception
|
||||
{
|
||||
var result = await task;
|
||||
return result ?? throw factory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Awaits the specified task and ensures that the result is not <c>empty</c>.
|
||||
/// If the result contains no elements, the exception created by factory-method is thrown.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The element type of the collection.</typeparam>
|
||||
/// <typeparam name="TException">The type of the exception.</typeparam>
|
||||
/// <param name="task">The task to await.</param>
|
||||
/// <param name="factory">Exception provider</param>
|
||||
/// <returns>The awaited collection if it is not <c>null</c> or empty.</returns>
|
||||
/// <exception cref="NotFoundException">Thrown if the result is <c>null</c> or empty.</exception>
|
||||
public static async Task<IEnumerable<T>> ThrowIfNull<T, TException>(this Task<IEnumerable<T>> task, Func<TException> factory) where TException : Exception
|
||||
{
|
||||
var result = await task;
|
||||
return result?.Any() ?? false ? result : throw factory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="I"></typeparam>
|
||||
/// <param name="task"></param>
|
||||
/// <param name="act"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<I> Then<T, I>(this Task<T> task, Func<T, I> act)
|
||||
{
|
||||
var res = await task;
|
||||
return act(res);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static NotFoundException NotFound() => new();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static BadRequestException BadRequest() => new();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static ForbiddenException Forbidden() => new();
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Application.Model;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Histories.Commands;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public record CreateHistoryCommand : IRequest<long?>
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int EnvelopeId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string UserReference { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public Constants.EnvelopeStatus Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public DateTime AddedWhen { get; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public DateTime ActionDate => AddedWhen;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string? Comment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public EnvelopeQueryBase? Envelope { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// /
|
||||
/// </summary>
|
||||
public ReceiverQueryBase? Receiver { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CreateHistoryCommandHandler : IRequestHandler<CreateHistoryCommand, long?>
|
||||
{
|
||||
private readonly IRepository<EnvelopeHistory> _repo;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="repo"></param>
|
||||
public CreateHistoryCommandHandler(IRepository<EnvelopeHistory> repo)
|
||||
{
|
||||
_repo = repo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<long?> Handle(CreateHistoryCommand request, CancellationToken cancel)
|
||||
{
|
||||
// create entitiy
|
||||
await _repo.CreateAsync(request, cancel);
|
||||
|
||||
// check if created
|
||||
var record = await _repo.ReadOnly()
|
||||
.Where(h => h.EnvelopeId == request.EnvelopeId)
|
||||
.Where(h => h.UserReference == request.UserReference)
|
||||
.Where(h => h.ActionDate == request.ActionDate)
|
||||
.SingleOrDefaultAsync(cancel);
|
||||
|
||||
return record?.Id;
|
||||
}
|
||||
}
|
||||
21
EnvelopeGenerator.Application/Histories/MappingProfile.cs
Normal file
21
EnvelopeGenerator.Application/Histories/MappingProfile.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.Histories.Commands;
|
||||
using EnvelopeGenerator.Application.Histories.Queries.Read;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Histories;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class MappingProfile: Profile
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public MappingProfile()
|
||||
{
|
||||
CreateMap<EnvelopeHistory, ReadHistoryResponse>();
|
||||
CreateMap<CreateHistoryCommand, EnvelopeHistory>();
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Histories.Queries.Read;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ReadHistoryMappingProfile: Profile
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public ReadHistoryMappingProfile()
|
||||
{
|
||||
CreateMap<EnvelopeHistory, ReadHistoryResponse>();
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,8 @@ namespace EnvelopeGenerator.Application.Histories.Queries.Read;
|
||||
/// Repräsentiert eine Abfrage für die Verlaufshistorie eines Umschlags.
|
||||
/// </summary>
|
||||
/// <param name="EnvelopeId">Die eindeutige Kennung des Umschlags.</param>
|
||||
/// <param name="Status">Der Status des Umschlags, der abgefragt werden soll. Kann optional angegeben werden, um die Ergebnisse zu filtern.</param>
|
||||
/// <param name="OnlyLast">Abfrage zur Steuerung, ob nur der aktuelle Status oder der gesamte Datensatz zurückgegeben wird.</param>
|
||||
/// <param name="Status">Der Include des Umschlags, der abgefragt werden soll. Kann optional angegeben werden, um die Ergebnisse zu filtern.</param>
|
||||
/// <param name="OnlyLast">Abfrage zur Steuerung, ob nur der aktuelle Include oder der gesamte Datensatz zurückgegeben wird.</param>
|
||||
public record ReadHistoryQuery(
|
||||
[Required]
|
||||
int EnvelopeId,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
using EnvelopeGenerator.Application.Exceptions;
|
||||
using EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
using DigitalData.Core.Exceptions;
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Histories.Queries.Read;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,7 +1,7 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
@@ -1,7 +1,7 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -2,7 +2,7 @@
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,7 +1,7 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -2,7 +2,7 @@
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,7 +1,7 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,7 +1,8 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -83,7 +84,7 @@ public interface IEnvelopeReceiverRepository : ICRUDRepository<EnvelopeReceiver,
|
||||
/// <param name="max_status"></param>
|
||||
/// <param name="ignore_statuses"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<EnvelopeReceiver>> ReadByUsernameAsync(string username, int? min_status = null, int? max_status = null, params int[] ignore_statuses);
|
||||
Task<IEnumerable<EnvelopeReceiver>> ReadByUsernameAsync(string username, Constants.EnvelopeStatus? min_status = null, Constants.EnvelopeStatus? max_status = null, params Constants.EnvelopeStatus[] ignore_statuses);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,7 +1,8 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -38,5 +39,5 @@ public interface IEnvelopeRepository : ICRUDRepository<Envelope, int>
|
||||
/// <param name="max_status"></param>
|
||||
/// <param name="ignore_statuses"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<Envelope>> ReadByUserAsync(int userId, int? min_status = null, int? max_status = null, params int[] ignore_statuses);
|
||||
Task<IEnumerable<Envelope>> ReadByUserAsync(int userId, Constants.EnvelopeStatus? min_status = null, Constants.EnvelopeStatus? max_status = null, params Constants.EnvelopeStatus[] ignore_statuses);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,7 +1,7 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Repositories;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Repositories;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,6 +1,6 @@
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.SQLExecutor;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,7 +1,7 @@
|
||||
using Dapper;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.SQLExecutor;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,6 +1,6 @@
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.SQLExecutor;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.SQLExecutor;
|
||||
|
||||
/// <summary>
|
||||
/// Provides methods for executing common queries on a given entity type.
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.SQLExecutor;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a raw SQL query contract.
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.SQLExecutor;
|
||||
|
||||
/// <summary>
|
||||
/// Defines methods for executing raw SQL queries or custom SQL query classes and returning query executors for further operations.
|
||||
@@ -1,6 +1,6 @@
|
||||
using Dapper;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.SQLExecutor;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,6 +1,6 @@
|
||||
using OtpNet;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Services;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,9 +1,9 @@
|
||||
using DigitalData.Core.Abstraction.Application;
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
using EnvelopeGenerator.Application.DTOs;
|
||||
using EnvelopeGenerator.Application.Dto;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Services;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,8 +1,8 @@
|
||||
using DigitalData.Core.Abstraction.Application;
|
||||
using EnvelopeGenerator.Application.DTOs;
|
||||
using EnvelopeGenerator.Application.Dto;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Services;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,7 +1,7 @@
|
||||
using DigitalData.Core.Abstraction.Application;
|
||||
using EnvelopeGenerator.Application.DTOs;
|
||||
using EnvelopeGenerator.Application.Dto;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Services;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,10 +1,10 @@
|
||||
using DigitalData.Core.Abstraction.Application;
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
using EnvelopeGenerator.Application.DTOs;
|
||||
using EnvelopeGenerator.Application.Dto;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Services;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,8 +1,8 @@
|
||||
using DigitalData.Core.Abstraction.Application;
|
||||
using EnvelopeGenerator.Application.DTOs;
|
||||
using EnvelopeGenerator.Application.Dto;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Services;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,11 +1,11 @@
|
||||
using DigitalData.Core.Abstraction.Application;
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
using EnvelopeGenerator.Application.DTOs.EnvelopeHistory;
|
||||
using EnvelopeGenerator.Application.DTOs.Receiver;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeHistory;
|
||||
using EnvelopeGenerator.Application.Dto.Receiver;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using static EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Services;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,10 +1,10 @@
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
using DigitalData.EmailProfilerDispatcher.Abstraction.Contracts;
|
||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeReceiver;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeReceiverReadOnly;
|
||||
using EnvelopeGenerator.Domain;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Services;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,8 +1,8 @@
|
||||
using DigitalData.Core.Abstraction.Application;
|
||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeReceiverReadOnly;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Services;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -1,13 +1,15 @@
|
||||
using CommandDotNet;
|
||||
using DigitalData.Core.Abstraction.Application;
|
||||
using DigitalData.Core.Abstraction.Application.DTO;
|
||||
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiver;
|
||||
using EnvelopeGenerator.Application.DTOs.Messaging;
|
||||
using EnvelopeGenerator.Application.Dto.EnvelopeReceiver;
|
||||
using EnvelopeGenerator.Application.Dto.Messaging;
|
||||
using EnvelopeGenerator.Application.Envelopes;
|
||||
using EnvelopeGenerator.Application.Receivers.Queries.Read;
|
||||
using EnvelopeGenerator.Application.Envelopes.Queries;
|
||||
using EnvelopeGenerator.Application.Receivers.Queries;
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Contracts.Services;
|
||||
namespace EnvelopeGenerator.Application.Interfaces.Services;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -120,7 +122,7 @@ public interface IEnvelopeReceiverService : IBasicCRUDService<EnvelopeReceiverDt
|
||||
/// <param name="receiverQuery"></param>
|
||||
/// <param name="ignore_statuses"></param>
|
||||
/// <returns></returns>
|
||||
Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadByUsernameAsync(string username, int? min_status = null, int? max_status = null, EnvelopeQuery? envelopeQuery = null, ReadReceiverQuery? receiverQuery = null, params int[] ignore_statuses);
|
||||
Task<DataResult<IEnumerable<EnvelopeReceiverDto>>> ReadByUsernameAsync(string username, Constants.EnvelopeStatus? min_status = null, Constants.EnvelopeStatus? max_status = null, ReadEnvelopeQuery? envelopeQuery = null, ReadReceiverQuery? receiverQuery = null, params Constants.EnvelopeStatus[] ignore_statuses);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user