Compare commits
49 Commits
2fcea78574
...
web-multi-
| Author | SHA1 | Date | |
|---|---|---|---|
| f41199c389 | |||
| 03e3e0eaf4 | |||
| c8ca1ef22a | |||
| d31916eab8 | |||
| ee7c92ff5b | |||
| 89db852705 | |||
| c674a450d8 | |||
| 910a870ddf | |||
| e2afbc5a62 | |||
| 0fb94decdd | |||
| 2c81583831 | |||
| 47eade57a3 | |||
| d094fe14da | |||
| 0dc356726b | |||
| b227eb4051 | |||
| de36e29743 | |||
| 6291712291 | |||
| 73527a97d7 | |||
| ff094ebfe1 | |||
| 1c948fcbf8 | |||
| eba40acd4d | |||
| 5cb3465e12 | |||
| 2c43fdbaed | |||
| eb96842122 | |||
| a8cb8f935c | |||
| 387456659d | |||
| 17e3a67fe5 | |||
| 632723de5a | |||
| 6611b92fdb | |||
| 5baa28bac8 | |||
| c965975f82 | |||
| d480dd3a36 | |||
| ae7f0b80f3 | |||
| ef7c9c2b97 | |||
| 27f0aae8e0 | |||
| 1b10162c85 | |||
| bd0426dbee | |||
| b1551537c8 | |||
| 95b2ab5aed | |||
| ebed51b46a | |||
| 0d2425c9cf | |||
| c6c8747d23 | |||
| eb345a0e4d | |||
| 1b95b9d7e0 | |||
| d99193979f | |||
| 8742ea6025 | |||
| 2b8edc697a | |||
| 7c88d4ed4b | |||
| a6be907307 |
@@ -18,7 +18,7 @@ namespace EnvelopeGenerator.API.Controllers;
|
||||
/// <summary>
|
||||
/// Manages annotations and signature lifecycle for envelopes.
|
||||
/// </summary>
|
||||
[Authorize(Roles = Role.Receiver.FullyAuth)]
|
||||
[Authorize(Policy = AuthPolicy.Receiver)]
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class AnnotationController : ControllerBase
|
||||
@@ -54,7 +54,7 @@ public class AnnotationController : ControllerBase
|
||||
/// </summary>
|
||||
/// <param name="psPdfKitAnnotation">Annotation payload.</param>
|
||||
/// <param name="cancel">Cancellation token.</param>
|
||||
[Authorize(Roles = Role.Receiver.FullyAuth)]
|
||||
[Authorize(Policy = AuthPolicy.Receiver)]
|
||||
[HttpPost]
|
||||
[Obsolete("PSPDF Kit will no longer be used.")]
|
||||
public async Task<IActionResult> CreateOrUpdate([FromBody] PsPdfKitAnnotation? psPdfKitAnnotation = null, CancellationToken cancel = default)
|
||||
@@ -87,7 +87,7 @@ public class AnnotationController : ControllerBase
|
||||
/// Rejects the document for the current receiver.
|
||||
/// </summary>
|
||||
/// <param name="reason">Optional rejection reason.</param>
|
||||
[Authorize(Roles = Role.Receiver.FullyAuth)]
|
||||
[Authorize(Policy = AuthPolicy.Receiver)]
|
||||
[HttpPost("reject")]
|
||||
[Obsolete("Use MediatR")]
|
||||
public async Task<IActionResult> Reject([FromBody] string? reason = null)
|
||||
|
||||
@@ -1,19 +1,27 @@
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using EnvelopeGenerator.API.Controllers.Interfaces;
|
||||
using EnvelopeGenerator.API.Models;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace EnvelopeGenerator.API.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// Controller verantwortlich für die Benutzer-Authentifizierung, einschließlich Anmelden, Abmelden und Überprüfung des Authentifizierungsstatus.
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public partial class AuthController(ILogger<AuthController> logger) : ControllerBase
|
||||
public partial class AuthController(IOptions<AuthTokenKeys> authTokenKeyOptions, IAuthorizationService authService) : ControllerBase, IAuthController
|
||||
{
|
||||
private readonly AuthTokenKeys authTokenKeys = authTokenKeyOptions.Value;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public IAuthorizationService AuthService { get; } = authService;
|
||||
|
||||
/// <summary>
|
||||
/// Entfernt das Authentifizierungs-Cookie des Benutzers (AuthCookie)
|
||||
@@ -29,13 +37,19 @@ public partial class AuthController(ILogger<AuthController> logger) : Controller
|
||||
/// </remarks>
|
||||
/// <response code="200">Erfolgreich gelöscht, wenn der Benutzer ein berechtigtes Cookie hat.</response>
|
||||
/// <response code="401">Wenn es kein zugelassenes Cookie gibt, wird „nicht zugelassen“ zurückgegeben.</response>
|
||||
[ProducesResponseType(typeof(string), StatusCodes.Status200OK, "text/javascript")]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||
[Authorize]
|
||||
[Authorize(Policy = AuthPolicy.SenderOrReceiver)]
|
||||
[HttpPost("logout")]
|
||||
public async Task<IActionResult> Logout()
|
||||
{
|
||||
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
||||
if (await this.IsUserInPolicyAsync(AuthPolicy.Sender))
|
||||
Response.Cookies.Delete(authTokenKeys.Cookie);
|
||||
else if (await this.IsUserInPolicyAsync(AuthPolicy.ReceiverOrReceiverTFA))
|
||||
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
||||
else
|
||||
return Unauthorized();
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
@@ -51,9 +65,12 @@ public partial class AuthController(ILogger<AuthController> logger) : Controller
|
||||
/// </remarks>
|
||||
/// <response code="200">Wenn es einen autorisierten Cookie gibt.</response>
|
||||
/// <response code="401">Wenn kein Cookie vorhanden ist oder nicht autorisierte.</response>
|
||||
[ProducesResponseType(typeof(string), StatusCodes.Status200OK, "text/javascript")]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(void), StatusCodes.Status401Unauthorized)]
|
||||
[HttpGet("check")]
|
||||
[Authorize]
|
||||
[HttpGet]
|
||||
public IActionResult IsAuthenticated() => Ok();
|
||||
public IActionResult Check(string? role = null)
|
||||
=> role is not null && !User.IsInRole(role)
|
||||
? Unauthorized()
|
||||
: Ok();
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using EnvelopeGenerator.API.Controllers.Interfaces;
|
||||
using EnvelopeGenerator.API.Extensions;
|
||||
using EnvelopeGenerator.Application.Documents.Queries;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
@@ -16,19 +17,24 @@ namespace EnvelopeGenerator.API.Controllers;
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class DocumentController(IMediator mediator, ILogger<DocumentController> logger) : ControllerBase
|
||||
public class DocumentController(IMediator mediator, IAuthorizationService authService) : ControllerBase, IAuthController
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public IAuthorizationService AuthService => authService;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the document bytes receiver.
|
||||
/// </summary>
|
||||
/// <param name="query">Encoded envelope key.</param>
|
||||
/// <param name="cancel">Cancellation token.</param>
|
||||
[HttpGet]
|
||||
[Authorize(Roles = $"{Role.Sender},{Role.Receiver.FullyAuth}")]
|
||||
[Authorize(Policy = AuthPolicy.SenderOrReceiver)]
|
||||
public async Task<IActionResult> GetDocument(CancellationToken cancel, [FromQuery] ReadDocumentQuery? query = null)
|
||||
{
|
||||
// Sender: expects query with envelope key
|
||||
if (User.IsInRole(Role.Sender))
|
||||
if (await this.IsUserInPolicyAsync(AuthPolicy.Sender))
|
||||
{
|
||||
if (query is null)
|
||||
return BadRequest("Missing document query.");
|
||||
@@ -40,7 +46,7 @@ public class DocumentController(IMediator mediator, ILogger<DocumentController>
|
||||
}
|
||||
|
||||
// Receiver: resolve envelope id from claims
|
||||
if (User.IsInRole(Role.Receiver.FullyAuth))
|
||||
if (await this.IsUserInPolicyAsync(AuthPolicy.Receiver))
|
||||
{
|
||||
if (query is not null)
|
||||
return BadRequest("Query parameters are not allowed for receiver role.");
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.EmailTemplates;
|
||||
using EnvelopeGenerator.Application.EmailTemplates.Commands.Update;
|
||||
using EnvelopeGenerator.Application.EmailTemplates.Commands.Reset;
|
||||
using EnvelopeGenerator.Application.EmailTemplates.Queries.Read;
|
||||
using EnvelopeGenerator.Application.EmailTemplates.Commands;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MediatR;
|
||||
using System.Threading.Tasks;
|
||||
using EnvelopeGenerator.Application.Common.Dto;
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Application.EmailTemplates.Queries;
|
||||
|
||||
namespace EnvelopeGenerator.API.Controllers;
|
||||
|
||||
@@ -18,32 +16,18 @@ namespace EnvelopeGenerator.API.Controllers;
|
||||
/// Controller for managing temp templates.
|
||||
/// Steuerung zur Verwaltung von E-Mail-Vorlagen.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Initialisiert eine neue Instanz der <see cref="EmailTemplateController"/>-Klasse.
|
||||
/// </remarks>
|
||||
/// <param name="mapper">
|
||||
/// <param name="repository">
|
||||
/// Die AutoMapper-Instanz, die zum Zuordnen von Objekten verwendet wird.
|
||||
/// </param>
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class EmailTemplateController : ControllerBase
|
||||
[Authorize(Policy = AuthPolicy.Sender)]
|
||||
public class EmailTemplateController(IMapper mapper, IRepository<EmailTemplate> repository, IMediator mediator) : ControllerBase
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
private readonly IRepository<EmailTemplate> _repository;
|
||||
|
||||
private readonly IMediator _mediator;
|
||||
|
||||
/// <summary>
|
||||
/// Initialisiert eine neue Instanz der <see cref="EmailTemplateController"/>-Klasse.
|
||||
/// </summary>
|
||||
/// <param name="mapper">
|
||||
/// <param name="repository">
|
||||
/// Die AutoMapper-Instanz, die zum Zuordnen von Objekten verwendet wird.
|
||||
/// </param>
|
||||
[Obsolete("Use MediatR")]
|
||||
public EmailTemplateController(IMapper mapper, IRepository<EmailTemplate> repository, IMediator mediator)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_repository = repository;
|
||||
_mediator = mediator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ruft E-Mail-Vorlagen basierend auf der angegebenen Abfrage ab.
|
||||
/// Gibt alles zurück, wenn keine Id- oder Typ-Informationen eingegeben wurden.
|
||||
@@ -63,12 +47,12 @@ public class EmailTemplateController : ControllerBase
|
||||
{
|
||||
if (emailTemplate is null || (emailTemplate.Id is null && emailTemplate.Type is null))
|
||||
{
|
||||
var temps = await _repository.Query.ToListAsync();
|
||||
return Ok(_mapper.Map<IEnumerable<EmailTemplateDto>>(temps));
|
||||
var temps = await repository.Query.ToListAsync();
|
||||
return Ok(mapper.Map<IEnumerable<EmailTemplateDto>>(temps));
|
||||
}
|
||||
else
|
||||
{
|
||||
var temp = await _mediator.Send(emailTemplate);
|
||||
var temp = await mediator.Send(emailTemplate);
|
||||
return temp is null ? NotFound() : Ok(temp);
|
||||
}
|
||||
}
|
||||
@@ -77,40 +61,17 @@ public class EmailTemplateController : ControllerBase
|
||||
/// Updates an temp template or resets it if no update command is provided.
|
||||
/// Aktualisiert eine E-Mail-Vorlage oder setzt sie zurück, wenn kein Aktualisierungsbefehl angegeben ist.
|
||||
/// </summary>
|
||||
/// <param name="temp">Die E-Mail-Vorlagenabfrage.</param>
|
||||
/// <param name="update">Der Aktualisierungsbefehl für die E-Mail-Vorlage.
|
||||
/// Wird auf Standardwert aktualisiert, wenn die Anfrage ohne http-Body gesendet wird.
|
||||
/// </param>
|
||||
/// <returns>Gibt HTTP-Antwort zurück</returns>
|
||||
/// <remarks>
|
||||
/// Sample request:
|
||||
/// PUT /api/EmailTemplate
|
||||
/// {
|
||||
/// "emailTemplateId": 123,
|
||||
/// "newContent": "Updated content"
|
||||
/// }
|
||||
/// </remarks>
|
||||
/// <param name="update"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">Wenn die E-Mail-Vorlage erfolgreich aktualisiert oder zurückgesetzt wird.</response>
|
||||
/// <response code="400">Wenn die Abfrage ohne einen String gesendet wird.</response>
|
||||
/// <response code="401">Wenn der Benutzer nicht authentifiziert ist.</response>
|
||||
/// <response code="404">Wenn die gesuchte Abfrage nicht gefunden wird.</response>
|
||||
[HttpPut]
|
||||
public async Task<IActionResult> Update([FromQuery] EmailTemplateQuery? temp = null, [FromBody] UpdateEmailTemplateCommand? update = null)
|
||||
public async Task<IActionResult> Update([FromBody] UpdateEmailTemplateCommand update, CancellationToken cancel)
|
||||
{
|
||||
if (update is null)
|
||||
{
|
||||
await _mediator.Send(new ResetEmailTemplateCommand(temp));
|
||||
return Ok();
|
||||
}
|
||||
else if (temp is null)
|
||||
{
|
||||
return BadRequest("No both id and type");
|
||||
}
|
||||
else
|
||||
{
|
||||
update.EmailTemplateQuery = temp;
|
||||
await _mediator.Send(update);
|
||||
return Ok();
|
||||
}
|
||||
await mediator.Send(update, cancel);
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace EnvelopeGenerator.API.Controllers.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public interface IAuthController
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
IAuthorizationService AuthService { get; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
ClaimsPrincipal User { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class AuthControllerExtensions
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="controller"></param>
|
||||
/// <param name="policyName"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<bool> IsUserInPolicyAsync(this IAuthController controller, string policyName)
|
||||
{
|
||||
var result = await controller.AuthService.AuthorizeAsync(controller.User, policyName);
|
||||
return result.Succeeded;
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class ReadOnlyController : ControllerBase
|
||||
/// </summary>
|
||||
/// <param name="createDto">Creation payload.</param>
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Role.Receiver.FullyAuth)]
|
||||
[Authorize(Policy = AuthPolicy.Receiver)]
|
||||
public async Task<IActionResult> CreateAsync([FromBody] EnvelopeReceiverReadOnlyCreateDto createDto)
|
||||
{
|
||||
var authReceiverMail = User.GetReceiverMailOfReceiver();
|
||||
|
||||
@@ -111,7 +111,7 @@ public class TfaRegistrationController : ControllerBase
|
||||
/// <summary>
|
||||
/// Logs out the envelope receiver from cookie authentication.
|
||||
/// </summary>
|
||||
[Authorize(Roles = Role.FullyAuth)]
|
||||
[Authorize(Policy = AuthPolicy.Receiver)]
|
||||
[HttpPost("auth/logout")]
|
||||
public async Task<IActionResult> LogOutAsync()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using DigitalData.Core.API;
|
||||
using DigitalData.Core.Application;
|
||||
using EnvelopeGenerator.Infrastructure;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -93,7 +94,7 @@ try
|
||||
{
|
||||
Reference = new OpenApiReference
|
||||
{
|
||||
Type = ReferenceType.SecurityScheme,
|
||||
Type = Microsoft.OpenApi.Models.ReferenceType.SecurityScheme,
|
||||
Id = "Bearer"
|
||||
}
|
||||
},
|
||||
@@ -176,6 +177,16 @@ try
|
||||
options.SlidingExpiration = true;
|
||||
});
|
||||
|
||||
builder.Services.AddAuthorizationBuilder()
|
||||
.AddPolicy(AuthPolicy.SenderOrReceiver, policy =>
|
||||
policy.RequireRole(Role.Sender, Role.Receiver.Full))
|
||||
.AddPolicy(AuthPolicy.Sender, policy =>
|
||||
policy.RequireRole(Role.Sender))
|
||||
.AddPolicy(AuthPolicy.Receiver, policy =>
|
||||
policy.RequireRole(Role.Receiver.Full))
|
||||
.AddPolicy(AuthPolicy.ReceiverTFA, policy =>
|
||||
policy.RequireRole(Role.Receiver.TFA));
|
||||
|
||||
// User manager
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
builder.Services.AddUserManager<EGDbContext>();
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Common.Commands;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="TCommand"></typeparam>
|
||||
/// <typeparam name="TEntity"></typeparam>
|
||||
public class CreateCommandHandler<TCommand, TEntity> : IRequestHandler<TCommand, TEntity>
|
||||
where TCommand : class, IRequest<TEntity>
|
||||
where TEntity : class
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
protected readonly IRepository<TEntity> Repository;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="repository"></param>
|
||||
public CreateCommandHandler(IRepository<TEntity> repository)
|
||||
{
|
||||
Repository = repository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
public Task<TEntity> Handle(TCommand request, CancellationToken cancel) => Repository.CreateAsync(request, cancel);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using MediatR;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Common.Commands;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="TUpdateDto"></typeparam>
|
||||
/// <typeparam name="TEntity"></typeparam>
|
||||
public abstract record UpdateCommand<TUpdateDto, TEntity> : IRequest where TUpdateDto : class where TEntity : class
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public TUpdateDto Update { get; init; } = null!;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract Expression<Func<TEntity, bool>> BuildQueryExpression();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="TCommand"></typeparam>
|
||||
/// <typeparam name="TUpdateDto"></typeparam>
|
||||
/// <typeparam name="TEntity"></typeparam>
|
||||
public class UpdateCommandHandler<TCommand, TUpdateDto, TEntity> : IRequestHandler<TCommand>
|
||||
where TUpdateDto : class
|
||||
where TEntity : class
|
||||
where TCommand : UpdateCommand<TUpdateDto, TEntity>
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
protected readonly IRepository<TEntity> Repository;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="repository"></param>
|
||||
public UpdateCommandHandler(IRepository<TEntity> repository)
|
||||
{
|
||||
Repository = repository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
public Task Handle(TCommand request, CancellationToken cancel)
|
||||
=> Repository.UpdateAsync(request.Update, request.BuildQueryExpression(), cancel);
|
||||
}
|
||||
@@ -1,31 +1,37 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
namespace EnvelopeGenerator.Application.Common.Dto;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Common.Dto
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public record EmailTemplateDto
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
public record EmailTemplateDto
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Id{ get; init; }
|
||||
public int Id { get; init; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public required string Name { get; init; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public required string Name { get; init; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public required string Body { get; set; }
|
||||
/// <summary>
|
||||
/// Das Datum und die Uhrzeit, wann die Vorlage hinzugefügt wurde.
|
||||
/// </summary>
|
||||
public DateTime AddedWhen { get; init; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public required string Subject { get; set; }
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// Der Inhalt (Body) der E-Mail-Vorlage. Kann null sein.
|
||||
/// </summary>
|
||||
public string? Body { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Der Betreff der E-Mail-Vorlage. Kann null sein.
|
||||
/// </summary>
|
||||
public string? Subject { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Das Datum und die Uhrzeit, wann die Vorlage zuletzt geändert wurde. Kann null sein.
|
||||
/// </summary>
|
||||
public DateTime? ChangedWhen { get; init; }
|
||||
};
|
||||
@@ -28,8 +28,8 @@ public class MappingProfile : Profile
|
||||
CreateMap<EmailTemplate, EmailTemplateDto>();
|
||||
CreateMap<Envelope, EnvelopeDto>();
|
||||
CreateMap<Document, DocumentDto>();
|
||||
CreateMap<Domain.Entities.History, HistoryDto>();
|
||||
CreateMap<Domain.Entities.History, HistoryCreateDto>();
|
||||
CreateMap<Domain.Entities.History, HistoryDto>().ForMember(dest => dest.ActionDate, opt => opt.MapFrom(src => src.ChangedWhen));
|
||||
CreateMap<Domain.Entities.History, HistoryCreateDto>().ForMember(dest => dest.ActionDate, opt => opt.MapFrom(src => src.ChangedWhen));
|
||||
CreateMap<Domain.Entities.EnvelopeReceiver, EnvelopeReceiverDto>();
|
||||
CreateMap<Domain.Entities.EnvelopeReceiver, EnvelopeReceiverSecretDto>();
|
||||
CreateMap<EnvelopeType, EnvelopeTypeDto>();
|
||||
@@ -44,15 +44,15 @@ public class MappingProfile : Profile
|
||||
CreateMap<EmailTemplateDto, EmailTemplate>();
|
||||
CreateMap<EnvelopeDto, Envelope>();
|
||||
CreateMap<DocumentDto, Document>();
|
||||
CreateMap<HistoryDto, Domain.Entities.History>();
|
||||
CreateMap<HistoryCreateDto, Domain.Entities.History>();
|
||||
CreateMap<HistoryDto, Domain.Entities.History>().ForMember(dest => dest.ChangedWhen, opt => opt.MapFrom(src => src.ActionDate));
|
||||
CreateMap<HistoryCreateDto, Domain.Entities.History>().ForMember(dest => dest.ChangedWhen, opt => opt.MapFrom(src => src.ActionDate));
|
||||
CreateMap<EnvelopeReceiverDto, Domain.Entities.EnvelopeReceiver>();
|
||||
CreateMap<EnvelopeTypeDto, EnvelopeType>();
|
||||
CreateMap<ReceiverDto, Domain.Entities.Receiver>().ForMember(rcv => rcv.EnvelopeReceivers, rcvReadDto => rcvReadDto.Ignore());
|
||||
CreateMap<EnvelopeReceiverReadOnlyCreateDto, Domain.Entities.EnvelopeReceiverReadOnly>();
|
||||
CreateMap<EnvelopeReceiverReadOnlyUpdateDto, Domain.Entities.EnvelopeReceiverReadOnly>();
|
||||
CreateMap<AnnotationCreateDto, ElementAnnotation>()
|
||||
.ForMember(dest => dest.AddedWhen, opt => opt.MapFrom(_ => DateTime.UtcNow));
|
||||
.MapAddedWhen();
|
||||
|
||||
// Messaging mappings
|
||||
// for GTX messaging
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Domain.Interfaces.Auditing;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Common.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for applying auditing timestamps during AutoMapper mappings.
|
||||
/// </summary>
|
||||
public static class AutoMapperAuditingExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Maps <see cref="IHasAddedWhen.AddedWhen"/> to the current UTC time.
|
||||
/// </summary>
|
||||
public static IMappingExpression<TSource, TDestination> MapAddedWhen<TSource, TDestination>(this IMappingExpression<TSource, TDestination> expression)
|
||||
where TDestination : IHasAddedWhen
|
||||
=> expression.ForMember(dest => dest.AddedWhen, opt => opt.MapFrom(_ => DateTime.UtcNow));
|
||||
|
||||
/// <summary>
|
||||
/// Maps <see cref="IHasChangedWhen.ChangedWhen"/> to the current UTC time.
|
||||
/// </summary>
|
||||
public static IMappingExpression<TSource, TDestination> MapChangedWhen<TSource, TDestination>(this IMappingExpression<TSource, TDestination> expression)
|
||||
where TDestination : IHasChangedWhen
|
||||
=> expression.ForMember(dest => dest.ChangedWhen, opt => opt.MapFrom(_ => DateTime.UtcNow));
|
||||
}
|
||||
@@ -1,12 +1,31 @@
|
||||
namespace EnvelopeGenerator.Application.DocStatus.Commands;
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Application.Common.Commands;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.DocStatus.Commands;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public record CreateDocStatusCommand : ModifyDocStatusCommandBase
|
||||
public record CreateDocStatusCommand : ModifyDocStatusCommandBase, IRequest<DocumentStatus>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets timestamp when this record was added. Returns the StatusChangedWhen value.
|
||||
/// </summary>
|
||||
public DateTime AddedWhen => StatusChangedWhen;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class CreateDocStatusCommandHandler : CreateCommandHandler<CreateDocStatusCommand, DocumentStatus>
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="repository"></param>
|
||||
public CreateDocStatusCommandHandler(IRepository<DocumentStatus> repository) : base(repository)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.Common.Extensions;
|
||||
using EnvelopeGenerator.Application.DocStatus.Commands;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
|
||||
@@ -16,10 +17,12 @@ public class MappingProfile : Profile
|
||||
{
|
||||
CreateMap<CreateDocStatusCommand, DocumentStatus>()
|
||||
.ForMember(dest => dest.Envelope, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Receiver, opt => opt.Ignore());
|
||||
.ForMember(dest => dest.Receiver, opt => opt.Ignore())
|
||||
.MapAddedWhen();
|
||||
|
||||
CreateMap<UpdateDocStatusCommand, DocumentStatus>()
|
||||
.ForMember(dest => dest.Envelope, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Receiver, opt => opt.Ignore());
|
||||
.ForMember(dest => dest.Receiver, opt => opt.Ignore())
|
||||
.MapChangedWhen();
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using EnvelopeGenerator.Domain;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates.Commands.Reset;
|
||||
|
||||
/// <summary>
|
||||
/// Ein Befehl zum Zurücksetzen einer E-Mail-Vorlage auf die Standardwerte.
|
||||
/// Erbt von <see cref="EmailTemplateQuery"/> und ermöglicht die Angabe einer optionalen ID und eines Typs der E-Mail-Vorlage.<br/><br/>
|
||||
/// Beispiele:<br/>
|
||||
/// 0 - DocumentReceived: Benachrichtigung über den Empfang eines Dokuments.<br/>
|
||||
/// 1 - DocumentSigned: Benachrichtigung über die Unterzeichnung eines Dokuments.<br/>
|
||||
/// 2 - DocumentDeleted: Benachrichtigung über das Löschen eines Dokuments.<br/>
|
||||
/// 3 - DocumentCompleted: Benachrichtigung über den Abschluss eines Dokuments.<br/>
|
||||
/// 4 - DocumentAccessCodeReceived: Benachrichtigung über den Erhalt eines Zugangscodes.<br/>
|
||||
/// 5 - DocumentShared: Benachrichtigung über das Teilen eines Dokuments.<br/>
|
||||
/// 6 - TotpSecret: Benachrichtigung über ein TOTP-Geheimnis.<br/>
|
||||
/// 7 - DocumentRejected_ADM (Für den Absender): Mail an den Absender, wenn das Dokument abgelehnt wird.<br/>
|
||||
/// 8 - DocumentRejected_REC (Für den ablehnenden Empfänger): Mail an den ablehnenden Empfänger, wenn das Dokument abgelehnt wird.<br/>
|
||||
/// 9 - DocumentRejected_REC_2 (Für sonstige Empfänger): Mail an andere Empfänger (Brief), wenn das Dokument abgelehnt wird.<br/>
|
||||
/// </summary>
|
||||
public record ResetEmailTemplateCommand : EmailTemplateQuery, IRequest
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="orginal"></param>
|
||||
public ResetEmailTemplateCommand(EmailTemplateQuery? orginal = null) : base(orginal ?? new())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="Id">Die optionale ID der E-Mail-Vorlage, die zurückgesetzt werden soll.</param>
|
||||
/// <param name="Type">Der Typ der E-Mail-Vorlage, z. B. <see cref="EmailTemplateType"/> (optional).</param>
|
||||
public ResetEmailTemplateCommand(int? Id = null, EmailTemplateType? Type = null) : base(Id, Type)
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -1,11 +1,38 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using MediatR;
|
||||
using EnvelopeGenerator.Application.Common.Dto;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates.Commands.Reset;
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates.Commands;
|
||||
|
||||
/// <summary>
|
||||
/// Ein Befehl zum Zurücksetzen einer E-Mail-Vorlage auf die Standardwerte.
|
||||
/// Erbt von <see cref="IEmailTemplateQuery"/> und ermöglicht die Angabe einer optionalen ID und eines Typs der E-Mail-Vorlage.<br/><br/>
|
||||
/// </summary>
|
||||
public record ResetEmailTemplateCommand : IEmailTemplateQuery, IRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Die eindeutige Kennung der E-Mail-Vorlage (optional).
|
||||
/// </summary>
|
||||
public int? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Der Typ der E-Mail-Vorlage, z. B. <see cref="EmailTemplateType"/> (optional). Beispiele:<br/>
|
||||
/// 0 - DocumentReceived: Benachrichtigung über den Empfang eines Dokuments.<br/>
|
||||
/// 1 - DocumentSigned: Benachrichtigung über die Unterzeichnung eines Dokuments.<br/>
|
||||
/// 2 - DocumentDeleted: Benachrichtigung über das Löschen eines Dokuments.<br/>
|
||||
/// 3 - DocumentCompleted: Benachrichtigung über den Abschluss eines Dokuments.<br/>
|
||||
/// 4 - DocumentAccessCodeReceived: Benachrichtigung über den Erhalt eines Zugangscodes.<br/>
|
||||
/// 5 - DocumentShared: Benachrichtigung über das Teilen eines Dokuments.<br/>
|
||||
/// 6 - TotpSecret: Benachrichtigung über ein TOTP-Geheimnis.<br/>
|
||||
/// 7 - DocumentRejected_ADM (für den Absender): Mail an den Absender, wenn das Dokument abgelehnt wird.<br/>
|
||||
/// 8 - DocumentRejected_REC (für den ablehnenden Empfänger): Mail an den ablehnenden Empfänger, wenn das Dokument abgelehnt wird.<br/>
|
||||
/// 9 - DocumentRejected_REC_2 (für sonstige Empfänger): Mail an andere Empfänger (Brief), wenn das Dokument abgelehnt wird.
|
||||
/// </summary>
|
||||
public EmailTemplateType? Type { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -41,7 +68,7 @@ public class ResetEmailTemplateCommandHandler : IRequestHandler<ResetEmailTempla
|
||||
foreach (var temp in temps)
|
||||
{
|
||||
var def = Defaults.Where(t => t.Name == temp.Name).FirstOrDefault();
|
||||
if(def is not null)
|
||||
if (def is not null)
|
||||
await _repository.UpdateAsync(def, t => t.Id == temp.Id, cancel);
|
||||
}
|
||||
}
|
||||
@@ -113,4 +140,4 @@ public class ResetEmailTemplateCommandHandler : IRequestHandler<ResetEmailTempla
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
using MediatR;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates.Commands.Update;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Befehl zum Aktualisieren einer E-Mail-Vorlage.
|
||||
/// </summary>
|
||||
/// <param name="Body">
|
||||
/// (Optional)Der neue Inhalt des E-Mail-Textkörpers. Wenn null, bleibt der vorhandene Inhalt unverändert.
|
||||
/// </param>
|
||||
/// <param name="Subject">
|
||||
/// (Optional) Der neue Betreff der E-Mail. Wenn null, bleibt der vorhandene Betreff unverändert.
|
||||
/// </param>
|
||||
public record UpdateEmailTemplateCommand(string? Body = null, string? Subject = null) : IRequest
|
||||
{
|
||||
/// <param>
|
||||
/// Die Abfrage, die die E-Mail-Vorlage darstellt, die aktualisiert werden soll.
|
||||
/// </param>
|
||||
[JsonIgnore]
|
||||
public EmailTemplateQuery? EmailTemplateQuery { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public DateTime ChangedWhen { get; init; } = DateTime.Now;
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using DigitalData.Core.Exceptions;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Application.Common.Dto;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates.Commands.Update;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class UpdateEmailTemplateCommandHandler : IRequestHandler<UpdateEmailTemplateCommand>
|
||||
{
|
||||
private readonly IRepository<EmailTemplate> _repository;
|
||||
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="repository"></param>
|
||||
/// <param name="mapper"></param>
|
||||
public UpdateEmailTemplateCommandHandler(IRepository<EmailTemplate> repository, IMapper mapper)
|
||||
{
|
||||
_repository = repository;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="InvalidOperationException"></exception>
|
||||
/// <exception cref="NotFoundException"></exception>
|
||||
[Obsolete("Use Read-method returning IReadQuery<TEntity> instead.")]
|
||||
public async Task Handle(UpdateEmailTemplateCommand request, CancellationToken cancel)
|
||||
{
|
||||
EmailTemplateDto? tempDto;
|
||||
|
||||
if (request.EmailTemplateQuery?.Id is int id)
|
||||
{
|
||||
var temp = await _repository.ReadOnly().Where(t => t.Id == id).FirstOrDefaultAsync(cancel);
|
||||
tempDto = _mapper.Map<EmailTemplateDto>(temp);
|
||||
}
|
||||
else if (request!.EmailTemplateQuery!.Type is EmailTemplateType type)
|
||||
{
|
||||
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 (tempDto == null)
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
if (request.Body is not null)
|
||||
tempDto.Body = request.Body;
|
||||
|
||||
if (request.Subject is not null)
|
||||
tempDto.Subject = request.Subject;
|
||||
|
||||
await _repository.UpdateAsync(tempDto, t => t.Id == tempDto.Id, cancel);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Application.Common.Commands;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates.Commands;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="Body"></param>
|
||||
/// <param name="Subject"></param>
|
||||
public record EmailTemplateUpdateDto(string Body, string Subject);
|
||||
|
||||
/// <summary>
|
||||
/// Befehl zum Aktualisieren einer E-Mail-Vorlage.
|
||||
/// </summary>
|
||||
public record UpdateEmailTemplateCommand : UpdateCommand<EmailTemplateUpdateDto, EmailTemplate>, IEmailTemplateQuery
|
||||
{
|
||||
/// <summary>
|
||||
/// Die eindeutige Kennung der E-Mail-Vorlage (optional).
|
||||
/// </summary>
|
||||
public int? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Der Typ der E-Mail-Vorlage, z. B. <see cref="EmailTemplateType"/> (optional). Beispiele:<br/>
|
||||
/// 0 - DocumentReceived: Benachrichtigung über den Empfang eines Dokuments.<br/>
|
||||
/// 1 - DocumentSigned: Benachrichtigung über die Unterzeichnung eines Dokuments.<br/>
|
||||
/// 2 - DocumentDeleted: Benachrichtigung über das Löschen eines Dokuments.<br/>
|
||||
/// 3 - DocumentCompleted: Benachrichtigung über den Abschluss eines Dokuments.<br/>
|
||||
/// 4 - DocumentAccessCodeReceived: Benachrichtigung über den Erhalt eines Zugangscodes.<br/>
|
||||
/// 5 - DocumentShared: Benachrichtigung über das Teilen eines Dokuments.<br/>
|
||||
/// 6 - TotpSecret: Benachrichtigung über ein TOTP-Geheimnis.<br/>
|
||||
/// 7 - DocumentRejected_ADM (für den Absender): Mail an den Absender, wenn das Dokument abgelehnt wird.<br/>
|
||||
/// 8 - DocumentRejected_REC (für den ablehnenden Empfänger): Mail an den ablehnenden Empfänger, wenn das Dokument abgelehnt wird.<br/>
|
||||
/// 9 - DocumentRejected_REC_2 (für sonstige Empfänger): Mail an andere Empfänger (Brief), wenn das Dokument abgelehnt wird.
|
||||
/// </summary>
|
||||
public EmailTemplateType? Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override Expression<Func<EmailTemplate, bool>> BuildQueryExpression()
|
||||
=> Id is int id
|
||||
? temp => temp.Id == id
|
||||
: temp => temp!.Name == Type.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class UpdateEmailTemplateCommandHandler : UpdateCommandHandler<UpdateEmailTemplateCommand, EmailTemplateUpdateDto, EmailTemplate>
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="repository"></param>
|
||||
public UpdateEmailTemplateCommandHandler(IRepository<EmailTemplate> repository) : base(repository)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates;
|
||||
|
||||
/// <summary>
|
||||
/// Repräsentiert eine Abfrage für E-Mail-Vorlagen, die für Absender und Empfänger von Umschlägen verwendet werden.
|
||||
/// Die Standardkultur ist "de-DE".
|
||||
/// </summary>
|
||||
/// <param name="Id">Die eindeutige Kennung der E-Mail-Vorlage (optional).</param>
|
||||
/// <param name="Type">Der Typ der E-Mail-Vorlage, z. B. <see cref="EmailTemplateType"/> (optional). Beispiele:
|
||||
/// 0 - DocumentReceived: Benachrichtigung über den Empfang eines Dokuments.
|
||||
/// 1 - DocumentSigned: Benachrichtigung über die Unterzeichnung eines Dokuments.
|
||||
/// 2 - DocumentDeleted: Benachrichtigung über das Löschen eines Dokuments.
|
||||
/// 3 - DocumentCompleted: Benachrichtigung über den Abschluss eines Dokuments.
|
||||
/// 4 - DocumentAccessCodeReceived: Benachrichtigung über den Erhalt eines Zugangscodes.
|
||||
/// 5 - DocumentShared: Benachrichtigung über das Teilen eines Dokuments.
|
||||
/// 6 - TotpSecret: Benachrichtigung über ein TOTP-Geheimnis.
|
||||
/// 7 - DocumentRejected_ADM (Für den Absender): Mail an den Absender, wenn das Dokument abgelehnt wird.
|
||||
/// 8 - DocumentRejected_REC (Für den ablehnenden Empfänger): Mail an den ablehnenden Empfänger, wenn das Dokument abgelehnt wird.
|
||||
/// 9 - DocumentRejected_REC_2 (Für sonstige Empfänger): Mail an andere Empfänger (Brief), wenn das Dokument abgelehnt wird.
|
||||
/// </param>
|
||||
public record EmailTemplateQuery(int? Id = null, EmailTemplateType? Type = null)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates;
|
||||
|
||||
/// <summary>
|
||||
/// Stellt eine Schnittstelle für Abfragen von E-Mail-Vorlagen dar, die für Absender und Empfänger von Umschlägen verwendet werden.
|
||||
/// Die Standardkultur ist "de-DE".
|
||||
/// </summary>
|
||||
public interface IEmailTemplateQuery
|
||||
{
|
||||
/// <summary>
|
||||
/// Die eindeutige Kennung der E-Mail-Vorlage (optional).
|
||||
/// </summary>
|
||||
int? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Der Typ der E-Mail-Vorlage, z. B. <see cref="EmailTemplateType"/> (optional). Beispiele:<br/>
|
||||
/// 0 - DocumentReceived: Benachrichtigung über den Empfang eines Dokuments.<br/>
|
||||
/// 1 - DocumentSigned: Benachrichtigung über die Unterzeichnung eines Dokuments.<br/>
|
||||
/// 2 - DocumentDeleted: Benachrichtigung über das Löschen eines Dokuments.<br/>
|
||||
/// 3 - DocumentCompleted: Benachrichtigung über den Abschluss eines Dokuments.<br/>
|
||||
/// 4 - DocumentAccessCodeReceived: Benachrichtigung über den Erhalt eines Zugangscodes.<br/>
|
||||
/// 5 - DocumentShared: Benachrichtigung über das Teilen eines Dokuments.<br/>
|
||||
/// 6 - TotpSecret: Benachrichtigung über ein TOTP-Geheimnis.<br/>
|
||||
/// 7 - DocumentRejected_ADM (für den Absender): Mail an den Absender, wenn das Dokument abgelehnt wird.<br/>
|
||||
/// 8 - DocumentRejected_REC (für den ablehnenden Empfänger): Mail an den ablehnenden Empfänger, wenn das Dokument abgelehnt wird.<br/>
|
||||
/// 9 - DocumentRejected_REC_2 (für sonstige Empfänger): Mail an andere Empfänger (Brief), wenn das Dokument abgelehnt wird.
|
||||
/// </summary>
|
||||
EmailTemplateType? Type { get; set; }
|
||||
}
|
||||
@@ -1,24 +1,24 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.EmailTemplates.Queries.Read;
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.Common.Dto;
|
||||
using EnvelopeGenerator.Application.Common.Extensions;
|
||||
using EnvelopeGenerator.Application.EmailTemplates.Commands;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public class MappingProfile : Profile
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public MappingProfile()
|
||||
{
|
||||
CreateMap<EmailTemplate, ReadEmailTemplateResponse>();
|
||||
CreateMap<EmailTemplate, EmailTemplateDto>();
|
||||
|
||||
CreateMap<EmailTemplateUpdateDto, EmailTemplate>()
|
||||
.MapChangedWhen();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates.Queries.Read;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Stellt eine Abfrage dar, um eine E-Mail-Vorlage zu lesen.
|
||||
/// Diese Klasse erbt von <see cref="EmailTemplateQuery"/>.
|
||||
/// </summary>
|
||||
public record ReadEmailTemplateQuery : EmailTemplateQuery, IRequest<ReadEmailTemplateResponse?>
|
||||
{
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
using AutoMapper;
|
||||
using EnvelopeGenerator.Application.Common.Interfaces.Repositories;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using MediatR;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates.Queries.Read;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ReadEmailTemplateQueryHandler : IRequestHandler<ReadEmailTemplateQuery, ReadEmailTemplateResponse?>
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
[Obsolete("Use Read-method returning IReadQuery<TEntity> instead.")]
|
||||
private readonly IEmailTemplateRepository _repository;
|
||||
|
||||
/// <summary>
|
||||
/// Initialisiert eine neue Instanz der <see cref="EmailTemplateController"/>-Klasse.
|
||||
/// </summary>
|
||||
/// <param name="mapper">
|
||||
/// <param name="repository">
|
||||
/// Die AutoMapper-Instanz, die zum Zuordnen von Objekten verwendet wird.
|
||||
/// </param>
|
||||
[Obsolete("Use Read-method returning IReadQuery<TEntity> instead.")]
|
||||
public ReadEmailTemplateQueryHandler(IMapper mapper, IEmailTemplateRepository repository)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="InvalidOperationException"></exception>
|
||||
[Obsolete("Use IRepository")]
|
||||
public async Task<ReadEmailTemplateResponse?> Handle(ReadEmailTemplateQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var temp = request.Id is int id
|
||||
? await _repository.ReadByIdAsync(id)
|
||||
: request.Type is EmailTemplateType type
|
||||
? await _repository.ReadByNameAsync(type)
|
||||
: throw new InvalidOperationException("Either a valid integer ID or a valid EmailTemplateType must be provided in the request.");
|
||||
|
||||
var res = _mapper.Map<ReadEmailTemplateResponse>(temp);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates.Queries.Read;
|
||||
|
||||
/// <summary>
|
||||
/// Stellt die Antwort für eine Abfrage von E-Mail-Vorlagen bereit.
|
||||
/// </summary>
|
||||
public class ReadEmailTemplateResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Die eindeutige Kennung der E-Mail-Vorlage.
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Name des Typs
|
||||
/// </summary>
|
||||
public required string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Das Datum und die Uhrzeit, wann die Vorlage hinzugefügt wurde.
|
||||
/// </summary>
|
||||
public DateTime AddedWhen { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Der Inhalt (Body) der E-Mail-Vorlage. Kann null sein.
|
||||
/// </summary>
|
||||
public string? Body { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Der Betreff der E-Mail-Vorlage. Kann null sein.
|
||||
/// </summary>
|
||||
public string? Subject { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Das Datum und die Uhrzeit, wann die Vorlage zuletzt geändert wurde. Kann null sein.
|
||||
/// </summary>
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using AutoMapper;
|
||||
using MediatR;
|
||||
using EnvelopeGenerator.Application.Common.Dto;
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using EnvelopeGenerator.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using DigitalData.Core.Exceptions;
|
||||
|
||||
namespace EnvelopeGenerator.Application.EmailTemplates.Queries;
|
||||
|
||||
/// <summary>
|
||||
/// Stellt eine Abfrage dar, um eine E-Mail-Vorlage zu lesen.
|
||||
/// Diese Klasse erbt von <see cref="IEmailTemplateQuery"/>.
|
||||
/// </summary>
|
||||
public record ReadEmailTemplateQuery : IEmailTemplateQuery, IRequest<EmailTemplateDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// Die eindeutige Kennung der E-Mail-Vorlage (optional).
|
||||
/// </summary>
|
||||
public int? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Der Typ der E-Mail-Vorlage, z. B. <see cref="EmailTemplateType"/> (optional). Beispiele:<br/>
|
||||
/// 0 - DocumentReceived: Benachrichtigung über den Empfang eines Dokuments.<br/>
|
||||
/// 1 - DocumentSigned: Benachrichtigung über die Unterzeichnung eines Dokuments.<br/>
|
||||
/// 2 - DocumentDeleted: Benachrichtigung über das Löschen eines Dokuments.<br/>
|
||||
/// 3 - DocumentCompleted: Benachrichtigung über den Abschluss eines Dokuments.<br/>
|
||||
/// 4 - DocumentAccessCodeReceived: Benachrichtigung über den Erhalt eines Zugangscodes.<br/>
|
||||
/// 5 - DocumentShared: Benachrichtigung über das Teilen eines Dokuments.<br/>
|
||||
/// 6 - TotpSecret: Benachrichtigung über ein TOTP-Geheimnis.<br/>
|
||||
/// 7 - DocumentRejected_ADM (für den Absender): Mail an den Absender, wenn das Dokument abgelehnt wird.<br/>
|
||||
/// 8 - DocumentRejected_REC (für den ablehnenden Empfänger): Mail an den ablehnenden Empfänger, wenn das Dokument abgelehnt wird.<br/>
|
||||
/// 9 - DocumentRejected_REC_2 (für sonstige Empfänger): Mail an andere Empfänger (Brief), wenn das Dokument abgelehnt wird.
|
||||
/// </summary>
|
||||
public EmailTemplateType? Type { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ReadEmailTemplateQueryHandler : IRequestHandler<ReadEmailTemplateQuery, EmailTemplateDto>
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
private readonly IRepository<EmailTemplate> _repo;
|
||||
|
||||
/// <summary>
|
||||
/// Initialisiert eine neue Instanz der <see cref="EmailTemplateController"/>-Klasse.
|
||||
/// </summary>
|
||||
/// <param name="mapper">
|
||||
/// <param name="repo">
|
||||
/// Die AutoMapper-Instanz, die zum Zuordnen von Objekten verwendet wird.
|
||||
/// </param>
|
||||
public ReadEmailTemplateQueryHandler(IMapper mapper, IRepository<EmailTemplate> repo)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_repo = repo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="cancel"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="InvalidOperationException"></exception>
|
||||
public async Task<EmailTemplateDto> Handle(ReadEmailTemplateQuery request, CancellationToken cancel)
|
||||
{
|
||||
var query = request.Id is int id
|
||||
? _repo.Query.Where(temp => temp.Id == id)
|
||||
: _repo.Query.Where(temp => temp.Name == request.Type!.ToString());
|
||||
|
||||
var entity = await query.FirstOrDefaultAsync(cancel) ?? throw new NotFoundException();
|
||||
|
||||
return _mapper.Map<EmailTemplateDto>(entity);
|
||||
}
|
||||
}
|
||||
15
EnvelopeGenerator.Domain/Constants/AuthPolicy.cs
Normal file
15
EnvelopeGenerator.Domain/Constants/AuthPolicy.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace EnvelopeGenerator.Domain.Constants
|
||||
{
|
||||
public static class AuthPolicy
|
||||
{
|
||||
public const string SenderOrReceiver = nameof(SenderOrReceiver) + nameof(AuthPolicy);
|
||||
|
||||
public const string ReceiverOrReceiverTFA = nameof(ReceiverOrReceiverTFA) + nameof(AuthPolicy);
|
||||
|
||||
public const string Sender = nameof(Sender) + nameof(AuthPolicy);
|
||||
|
||||
public const string Receiver = nameof(Receiver) + nameof(AuthPolicy);
|
||||
|
||||
public const string ReceiverTFA = nameof(ReceiverTFA) + nameof(AuthPolicy);
|
||||
}
|
||||
}
|
||||
@@ -6,18 +6,18 @@ namespace EnvelopeGenerator.Domain.Constants
|
||||
{
|
||||
public static class Role
|
||||
{
|
||||
[Obsolete("Use Receiver.PreAuth or Receiver.FullyAuth")]
|
||||
public const string PreAuth = "PreAuth";
|
||||
[Obsolete("Use Receiver.TFA")]
|
||||
public const string ReceiverTFA = Receiver.TFA;
|
||||
|
||||
[Obsolete("Use Receiver.PreAuth or Receiver.FullyAuth")]
|
||||
public const string FullyAuth = "FullyAuth";
|
||||
[Obsolete("Use Receiver.Full")]
|
||||
public const string ReceiverFull = Receiver.Full;
|
||||
|
||||
public static class Receiver
|
||||
{
|
||||
public const string PreAuth = "PreAuth";
|
||||
public const string FullyAuth = "FullyAuth";
|
||||
public const string TFA = "EGReceiverTFA";
|
||||
public const string Full = "EGReceiver";
|
||||
}
|
||||
|
||||
public const string Sender = "Sender";
|
||||
public const string Sender = "EGSender";
|
||||
}
|
||||
}
|
||||
@@ -2,30 +2,22 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace EnvelopeGenerator.Domain.Entities
|
||||
#if NET
|
||||
;
|
||||
#elif NETFRAMEWORK
|
||||
{
|
||||
#endif
|
||||
|
||||
[Table("TBSIG_CONFIG", Schema = "dbo")]
|
||||
public class Config
|
||||
{
|
||||
[Column("SENDING_PROFILE", TypeName = "int")]
|
||||
[Required]
|
||||
public int SendingProfile { get; set; }
|
||||
[Table("TBSIG_CONFIG", Schema = "dbo")]
|
||||
public class Config
|
||||
{
|
||||
[Column("SENDING_PROFILE", TypeName = "int")]
|
||||
[Required]
|
||||
public int SendingProfile { get; set; }
|
||||
|
||||
[Column("SIGNATURE_HOST", TypeName = "nvarchar(128)")]
|
||||
[Required]
|
||||
public string SignatureHost { get; set; }
|
||||
[Column("SIGNATURE_HOST", TypeName = "nvarchar(128)")]
|
||||
[Required]
|
||||
public string SignatureHost { get; set; }
|
||||
|
||||
[Column("EXTERNAL_PROGRAM_NAME", TypeName = "nvarchar(30)")]
|
||||
public string ExternalProgramName { get; set; }
|
||||
[Column("EXTERNAL_PROGRAM_NAME", TypeName = "nvarchar(30)")]
|
||||
public string ExternalProgramName { get; set; }
|
||||
|
||||
[Column("EXPORT_PATH", TypeName = "nvarchar(256)")]
|
||||
public string ExportPath { get; set; }
|
||||
}
|
||||
|
||||
#if NETFRAMEWORK
|
||||
[Column("EXPORT_PATH", TypeName = "nvarchar(256)")]
|
||||
public string ExportPath { get; set; }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
using EnvelopeGenerator.Domain.Interfaces;
|
||||
using System;
|
||||
using EnvelopeGenerator.Domain.Interfaces;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
using EnvelopeGenerator.Domain.Interfaces.Auditing;
|
||||
#if NETFRAMEWORK
|
||||
using System.Drawing;
|
||||
using System.Collections.Generic;
|
||||
@@ -8,81 +11,77 @@ using System.Linq;
|
||||
#endif
|
||||
|
||||
namespace EnvelopeGenerator.Domain.Entities
|
||||
#if NET
|
||||
;
|
||||
#elif NETFRAMEWORK
|
||||
{
|
||||
#endif
|
||||
|
||||
[Table("TBSIG_ENVELOPE_DOCUMENT", Schema = "dbo")]
|
||||
public class Document : IHasEnvelope
|
||||
{
|
||||
public Document()
|
||||
[Table("TBSIG_ENVELOPE_DOCUMENT", Schema = "dbo")]
|
||||
public class Document : IHasEnvelope, IHasAddedWhen
|
||||
{
|
||||
public Document()
|
||||
{
|
||||
#if NETFRAMEWORK
|
||||
Elements = Enumerable.Empty<Signature>().ToList();
|
||||
Elements = Enumerable.Empty<Signature>().ToList();
|
||||
#endif
|
||||
}
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("GUID")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ENVELOPE_ID")]
|
||||
public int EnvelopeId { get; set; }
|
||||
#if NETFRAMEWORK
|
||||
= 0;
|
||||
#endif
|
||||
|
||||
[Required]
|
||||
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||
public DateTime AddedWhen { get; set; }
|
||||
|
||||
[Column("BYTE_DATA", TypeName = "varbinary(max)")]
|
||||
public byte[]
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
ByteData { get; set; }
|
||||
|
||||
#region File
|
||||
[Column("FILENAME", TypeName = "nvarchar(256)")]
|
||||
public string Filename { get; set; }
|
||||
|
||||
[Column("FILEPATH", TypeName = "nvarchar(256)")]
|
||||
public string Filepath { get; set; }
|
||||
|
||||
[Column("FILENAME_ORIGINAL", TypeName = "nvarchar(256)")]
|
||||
public string
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
FileNameOriginal { get; set; }
|
||||
#endregion
|
||||
|
||||
public virtual List<Signature>
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Elements { get; set; }
|
||||
|
||||
[ForeignKey("EnvelopeId")]
|
||||
public virtual Envelope
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Envelope { get; set; }
|
||||
|
||||
#if NETFRAMEWORK
|
||||
[NotMapped]
|
||||
public bool IsTempFile { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public Bitmap Thumbnail { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public int PageCount { get; set; }
|
||||
#endif
|
||||
}
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("GUID")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ENVELOPE_ID")]
|
||||
public int EnvelopeId { get; set; }
|
||||
#if NETFRAMEWORK
|
||||
= 0;
|
||||
#endif
|
||||
|
||||
[Column("BYTE_DATA", TypeName = "varbinary(max)")]
|
||||
public byte[]
|
||||
#if NET
|
||||
?
|
||||
#endif
|
||||
ByteData { get; set; }
|
||||
|
||||
#region File
|
||||
[Column("FILENAME", TypeName = "nvarchar(256)")]
|
||||
public string Filename { get; set; }
|
||||
|
||||
[Column("FILEPATH", TypeName = "nvarchar(256)")]
|
||||
public string Filepath { get; set; }
|
||||
|
||||
[Column("FILENAME_ORIGINAL", TypeName = "nvarchar(256)")]
|
||||
public string
|
||||
#if NET
|
||||
?
|
||||
#endif
|
||||
FileNameOriginal { get; set; }
|
||||
#endregion
|
||||
|
||||
public virtual List<Signature>
|
||||
#if NET
|
||||
?
|
||||
#endif
|
||||
Elements { get; set; }
|
||||
|
||||
[ForeignKey("EnvelopeId")]
|
||||
public virtual Envelope
|
||||
#if NET
|
||||
?
|
||||
#endif
|
||||
Envelope { get; set; }
|
||||
|
||||
#if NETFRAMEWORK
|
||||
[NotMapped]
|
||||
public bool IsTempFile { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public Bitmap Thumbnail { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public int PageCount { get; set; }
|
||||
#endif
|
||||
}
|
||||
|
||||
#if NETFRAMEWORK
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,65 +1,62 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using DigitalData.Core.Abstractions.Interfaces;
|
||||
using EnvelopeGenerator.Domain.Interfaces;
|
||||
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
#endif
|
||||
using EnvelopeGenerator.Domain.Interfaces.Auditing;
|
||||
|
||||
namespace EnvelopeGenerator.Domain.Entities
|
||||
#if NET
|
||||
;
|
||||
#elif NETFRAMEWORK
|
||||
{
|
||||
#endif
|
||||
|
||||
[Table("TBSIG_DOCUMENT_STATUS", Schema = "dbo")]
|
||||
public class DocumentStatus : IHasEnvelope, IHasReceiver, IEntity
|
||||
{
|
||||
public DocumentStatus()
|
||||
[Table("TBSIG_DOCUMENT_STATUS", Schema = "dbo")]
|
||||
public class DocumentStatus : IHasEnvelope, IHasReceiver, IEntity, IHasAddedWhen, IHasChangedWhen
|
||||
{
|
||||
// TODO: * check Form Application and remove default value
|
||||
public DocumentStatus()
|
||||
{
|
||||
// TODO: * check Form Application and remove default value
|
||||
#if NETFRAMEWORK
|
||||
Status = Constants.DocumentStatus.Created;
|
||||
Status = Constants.DocumentStatus.Created;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("GUID")]
|
||||
public int Id { get; set; }
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("GUID")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ENVELOPE_ID")]
|
||||
public int EnvelopeId { get; set; }
|
||||
[Required]
|
||||
[Column("ENVELOPE_ID")]
|
||||
public int EnvelopeId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("RECEIVER_ID")]
|
||||
public int ReceiverId { get; set; }
|
||||
[Required]
|
||||
[Column("RECEIVER_ID")]
|
||||
public int ReceiverId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("STATUS")]
|
||||
public Constants.DocumentStatus Status { get; set; }
|
||||
[Required]
|
||||
[Column("STATUS")]
|
||||
public Constants.DocumentStatus Status { get; set; }
|
||||
|
||||
[Column("VALUE", TypeName = "nvarchar(max)")]
|
||||
public string Value { get; set; }
|
||||
[Required]
|
||||
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||
public DateTime AddedWhen { get; set; }
|
||||
|
||||
[ForeignKey("EnvelopeId")]
|
||||
public virtual Envelope
|
||||
#if NET
|
||||
?
|
||||
[Column("CHANGED_WHEN", TypeName = "datetime")]
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
|
||||
[Column("VALUE", TypeName = "nvarchar(max)")]
|
||||
public string Value { get; set; }
|
||||
|
||||
[ForeignKey("EnvelopeId")]
|
||||
public virtual Envelope
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Envelope { get; set; }
|
||||
Envelope { get; set; }
|
||||
|
||||
[ForeignKey("ReceiverId")]
|
||||
public virtual Receiver
|
||||
#if NET
|
||||
?
|
||||
[ForeignKey("ReceiverId")]
|
||||
public virtual Receiver
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Receiver { get; set; }
|
||||
}
|
||||
|
||||
#if NETFRAMEWORK
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,92 +1,85 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using EnvelopeGenerator.Domain.Interfaces.Auditing;
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
#endif
|
||||
|
||||
namespace EnvelopeGenerator.Domain.Entities
|
||||
#if NET
|
||||
;
|
||||
#elif NETFRAMEWORK
|
||||
{
|
||||
#endif
|
||||
|
||||
[Table("TBSIG_DOCUMENT_RECEIVER_ELEMENT_ANNOTATION")]
|
||||
public class ElementAnnotation
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("GUID", TypeName = "bigint")]
|
||||
public long Id { get; set; }
|
||||
[Table("TBSIG_DOCUMENT_RECEIVER_ELEMENT_ANNOTATION")]
|
||||
public class ElementAnnotation : IHasAddedWhen, IUpdateAuditable
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("GUID", TypeName = "bigint")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ELEMENT_ID", TypeName = "int")]
|
||||
public int ElementId { get; set; }
|
||||
[Required]
|
||||
[Column("ELEMENT_ID", TypeName = "int")]
|
||||
public int ElementId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("NAME", TypeName = "nvarchar(100)")]
|
||||
[StringLength(100)]
|
||||
public string Name { get; set; }
|
||||
[Required]
|
||||
[Column("NAME", TypeName = "nvarchar(100)")]
|
||||
[StringLength(100)]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("VALUE", TypeName = "nvarchar(max)")]
|
||||
public string Value { get; set; }
|
||||
[Required]
|
||||
[Column("VALUE", TypeName = "nvarchar(max)")]
|
||||
public string Value { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("TYPE", TypeName = "nvarchar(50)")]
|
||||
public string Type { get; set; }
|
||||
[Required]
|
||||
[Column("TYPE", TypeName = "nvarchar(50)")]
|
||||
public string Type { get; set; }
|
||||
|
||||
[Column("POSITION_X", TypeName = "float")]
|
||||
public double
|
||||
#if NET
|
||||
?
|
||||
[Column("POSITION_X", TypeName = "float")]
|
||||
public double
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
X { get; set; }
|
||||
X { get; set; }
|
||||
|
||||
[Column("POSITION_Y", TypeName = "float")]
|
||||
public double
|
||||
#if NET
|
||||
?
|
||||
[Column("POSITION_Y", TypeName = "float")]
|
||||
public double
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Y { get; set; }
|
||||
Y { get; set; }
|
||||
|
||||
[Column("WIDTH", TypeName = "float")]
|
||||
public double
|
||||
#if NET
|
||||
?
|
||||
[Column("WIDTH", TypeName = "float")]
|
||||
public double
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Width { get; set; }
|
||||
Width { get; set; }
|
||||
|
||||
[Column("HEIGHT", TypeName = "float")]
|
||||
public double
|
||||
#if NET
|
||||
?
|
||||
[Column("HEIGHT", TypeName = "float")]
|
||||
public double
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Height { get; set; }
|
||||
Height { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||
public DateTime AddedWhen { get; set; }
|
||||
[Required]
|
||||
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||
public DateTime AddedWhen { get; set; }
|
||||
|
||||
[Column("CHANGED_WHEN", TypeName = "datetime")]
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
[Column("CHANGED_WHEN", TypeName = "datetime")]
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
|
||||
[Column("CHANGED_WHO", TypeName = "nvarchar(100)")]
|
||||
[StringLength(100)]
|
||||
public string
|
||||
#if NET
|
||||
?
|
||||
[Column("CHANGED_WHO", TypeName = "nvarchar(100)")]
|
||||
[StringLength(100)]
|
||||
public string
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
ChangedWho { get; set; }
|
||||
ChangedWho { get; set; }
|
||||
|
||||
[ForeignKey("ElementId")]
|
||||
public virtual Signature
|
||||
#if NET
|
||||
?
|
||||
[ForeignKey("ElementId")]
|
||||
public virtual Signature
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Element { get; set; }
|
||||
}
|
||||
|
||||
#if NETFRAMEWORK
|
||||
Element { get; set; }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,44 +1,39 @@
|
||||
using DigitalData.Core.Abstractions.Interfaces;
|
||||
using System;
|
||||
using DigitalData.Core.Abstractions.Interfaces;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
#endif
|
||||
using EnvelopeGenerator.Domain.Interfaces.Auditing;
|
||||
|
||||
namespace EnvelopeGenerator.Domain.Entities
|
||||
#if NET
|
||||
;
|
||||
#elif NETFRAMEWORK
|
||||
{
|
||||
#endif
|
||||
|
||||
[Table("TBSIG_EMAIL_TEMPLATE", Schema = "dbo")]
|
||||
public class EmailTemplate : IEntity
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("GUID")]
|
||||
public int Id { get; set; }
|
||||
[Table("TBSIG_EMAIL_TEMPLATE", Schema = "dbo")]
|
||||
public class EmailTemplate : IEntity, IHasAddedWhen, IHasChangedWhen
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("GUID")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("NAME", TypeName = "nvarchar(64)")]
|
||||
public string Name { get; set; }
|
||||
[Column("NAME", TypeName = "nvarchar(64)")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Column("BODY", TypeName = "nvarchar(max)")]
|
||||
public string Body { get; set; }
|
||||
[Column("BODY", TypeName = "nvarchar(max)")]
|
||||
public string Body { get; set; }
|
||||
|
||||
[Column("SUBJECT", TypeName = "nvarchar(512)")]
|
||||
public string Subject { get; set; }
|
||||
[Column("SUBJECT", TypeName = "nvarchar(512)")]
|
||||
public string Subject { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||
[DefaultValue("GETDATE()")]
|
||||
public DateTime AddedWhen { get; set; }
|
||||
[Required]
|
||||
[Column("LANG_CODE", TypeName = "varchar(5)")]
|
||||
public string LangCode { get; set; }
|
||||
|
||||
[Column("CHANGED_WHEN", TypeName = "datetime")]
|
||||
public DateTime ChangedWhen { get; set; }
|
||||
}
|
||||
[Required]
|
||||
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||
[DefaultValue("GETDATE()")]
|
||||
public DateTime AddedWhen { get; set; }
|
||||
|
||||
#if NETFRAMEWORK
|
||||
[Column("CHANGED_WHEN", TypeName = "datetime")]
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,208 +1,205 @@
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using System;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using EnvelopeGenerator.Domain.Interfaces.Auditing;
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
#endif
|
||||
|
||||
namespace EnvelopeGenerator.Domain.Entities
|
||||
#if NET
|
||||
;
|
||||
#elif NETFRAMEWORK
|
||||
{
|
||||
#endif
|
||||
|
||||
[Table("TBSIG_ENVELOPE", Schema = "dbo")]
|
||||
public class Envelope
|
||||
{
|
||||
public Envelope()
|
||||
[Table("TBSIG_ENVELOPE", Schema = "dbo")]
|
||||
public class Envelope : IHasAddedWhen, IHasChangedWhen
|
||||
{
|
||||
// TODO: * Check the Form App and remove the default value
|
||||
public Envelope()
|
||||
{
|
||||
// TODO: * Check the Form App and remove the default value
|
||||
#if NETFRAMEWORK
|
||||
Id = 0;
|
||||
Status = EnvelopeStatus.EnvelopeCreated;
|
||||
Uuid = Guid.NewGuid().ToString();
|
||||
Message = My.Resources.Envelope.Please_read_and_sign_this_document;
|
||||
Title= string.Empty;
|
||||
Comment = string.Empty;
|
||||
Language = "de-DE";
|
||||
SendReminderEmails = false;
|
||||
FirstReminderDays = 0;
|
||||
ReminderIntervalDays = 0;
|
||||
CertificationType = (int)Constants.CertificationType.AdvancedElectronicSignature;
|
||||
UseAccessCode = false;
|
||||
Documents = Enumerable.Empty<Document>().ToList();
|
||||
Histories = Enumerable.Empty<History>().ToList();
|
||||
EnvelopeReceivers = Enumerable.Empty<EnvelopeReceiver>().ToList();
|
||||
Id = 0;
|
||||
Status = EnvelopeStatus.EnvelopeCreated;
|
||||
Uuid = Guid.NewGuid().ToString();
|
||||
Message = My.Resources.Envelope.Please_read_and_sign_this_document;
|
||||
Title = string.Empty;
|
||||
Comment = string.Empty;
|
||||
Language = "de-DE";
|
||||
SendReminderEmails = false;
|
||||
FirstReminderDays = 0;
|
||||
ReminderIntervalDays = 0;
|
||||
CertificationType = (int)Constants.CertificationType.AdvancedElectronicSignature;
|
||||
UseAccessCode = false;
|
||||
Documents = Enumerable.Empty<Document>().ToList();
|
||||
Histories = Enumerable.Empty<History>().ToList();
|
||||
EnvelopeReceivers = Enumerable.Empty<EnvelopeReceiver>().ToList();
|
||||
#endif
|
||||
}
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("GUID")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("USER_ID")]
|
||||
public int UserId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("STATUS")]
|
||||
public EnvelopeStatus Status { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ENVELOPE_UUID", TypeName = "nvarchar(36)")]
|
||||
public string Uuid { get; set; }
|
||||
|
||||
[Column("MESSAGE", TypeName = "nvarchar(max)")]
|
||||
public string Message { get; set; }
|
||||
|
||||
[Column("EXPIRES_WHEN", TypeName = "datetime")]
|
||||
public DateTime? ExpiresWhen { get; set; }
|
||||
|
||||
[Column("EXPIRES_WARNING_WHEN", TypeName = "datetime")]
|
||||
public DateTime? ExpiresWarningWhen { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||
public DateTime AddedWhen { get; set; }
|
||||
|
||||
[Column("CHANGED_WHEN", TypeName = "datetime")]
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
|
||||
[Column("TITLE", TypeName = "nvarchar(128)")]
|
||||
public string
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Title
|
||||
{ get; set; }
|
||||
|
||||
[Column("COMMENT", TypeName = "nvarchar(128)")]
|
||||
public string Comment { get; set; }
|
||||
|
||||
[Column("CONTRACT_TYPE")]
|
||||
public int? ContractType { get; set; }
|
||||
|
||||
#if NETFRAMEWORK
|
||||
[NotMapped]
|
||||
public string ContractTypeTranslated => My.Resources.Model.ResourceManager.GetString(ContractType.ToString());
|
||||
#endif
|
||||
|
||||
[Column("LANGUAGE", TypeName = "nvarchar(5)")]
|
||||
public string Language { get; set; }
|
||||
|
||||
[Column("SEND_REMINDER_EMAILS")]
|
||||
public bool SendReminderEmails { get; set; }
|
||||
|
||||
[Column("FIRST_REMINDER_DAYS")]
|
||||
public int? FirstReminderDays { get; set; }
|
||||
|
||||
[Column("REMINDER_INTERVAL_DAYS")]
|
||||
public int? ReminderIntervalDays { get; set; }
|
||||
|
||||
[Column("ENVELOPE_TYPE")]
|
||||
public int? EnvelopeTypeId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[NotMapped]
|
||||
public bool ReadOnly => EnvelopeTypeId == 2;
|
||||
|
||||
[Column("CERTIFICATION_TYPE")]
|
||||
public int? CertificationType { get; set; }
|
||||
|
||||
[Column("USE_ACCESS_CODE")]
|
||||
public bool UseAccessCode { get; set; }
|
||||
|
||||
[Column("FINAL_EMAIL_TO_CREATOR")]
|
||||
public int? FinalEmailToCreator { get; set; }
|
||||
|
||||
[Column("FINAL_EMAIL_TO_RECEIVERS")]
|
||||
public int? FinalEmailToReceivers { get; set; }
|
||||
|
||||
[Column("EXPIRES_WHEN_DAYS")]
|
||||
public int? ExpiresWhenDays { get; set; }
|
||||
|
||||
[Column("EXPIRES_WARNING_WHEN_DAYS")]
|
||||
public int? ExpiresWarningWhenDays { get; set; }
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
public User User { get; set; }
|
||||
|
||||
[Column("TFA_ENABLED")]
|
||||
public bool TfaEnabled { get; set; }
|
||||
#if NETFRAMEWORK
|
||||
= false;
|
||||
#endif
|
||||
|
||||
[NotMapped]
|
||||
[Column("DOC_RESULT")]
|
||||
public byte[]
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
DocResult
|
||||
{ get; set; }
|
||||
|
||||
[ForeignKey("EnvelopeTypeId")]
|
||||
public virtual EnvelopeType
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Type
|
||||
{ get; set; }
|
||||
|
||||
#if NETFRAMEWORK
|
||||
[NotMapped]
|
||||
public string CURRENT_WORK_APP { get; set; } = "signFLOW GUI";
|
||||
|
||||
[NotMapped]
|
||||
public bool IsAlreadySent => Status > EnvelopeStatus.EnvelopeSaved;
|
||||
#endif
|
||||
|
||||
public List<Document>
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Documents
|
||||
{ get; set; }
|
||||
|
||||
public List<History>
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Histories
|
||||
{ get; set; }
|
||||
|
||||
public List<EnvelopeReceiver>
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
EnvelopeReceivers
|
||||
{ get; set; }
|
||||
|
||||
//#if NETFRAMEWORK
|
||||
/// <summary>
|
||||
/// Validates whether the receiver and document data are complete.
|
||||
/// </summary>
|
||||
public List<string> ValidateReceiverDocumentData()
|
||||
{
|
||||
var errors = new List<string>();
|
||||
|
||||
if (!Documents?.Any() ?? true)
|
||||
errors.Add(My.Resources.Envelope.Missing_Documents);
|
||||
|
||||
if (!EnvelopeReceivers?.Any() ?? true)
|
||||
errors.Add(My.Resources.Envelope.Missing_Receivers);
|
||||
|
||||
if (EnvelopeReceivers?.Any(r => !r.HasEmailAndName) ?? false)
|
||||
errors.Add(My.Resources.Envelope.Incomplete_Receivers);
|
||||
|
||||
return errors;
|
||||
}
|
||||
//#endif
|
||||
}
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("GUID")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("USER_ID")]
|
||||
public int UserId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("STATUS")]
|
||||
public EnvelopeStatus Status { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ENVELOPE_UUID", TypeName = "nvarchar(36)")]
|
||||
public string Uuid { get; set; }
|
||||
|
||||
[Column("MESSAGE", TypeName = "nvarchar(max)")]
|
||||
public string Message { get; set; }
|
||||
|
||||
[Column("EXPIRES_WHEN", TypeName = "datetime")]
|
||||
public DateTime? ExpiresWhen { get; set; }
|
||||
|
||||
[Column("EXPIRES_WARNING_WHEN", TypeName = "datetime")]
|
||||
public DateTime? ExpiresWarningWhen { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||
public DateTime AddedWhen { get; set; }
|
||||
|
||||
[Column("CHANGED_WHEN", TypeName = "datetime")]
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
|
||||
[Column("TITLE", TypeName = "nvarchar(128)")]
|
||||
public string
|
||||
#if NET
|
||||
?
|
||||
#endif
|
||||
Title { get; set; }
|
||||
|
||||
[Column("COMMENT", TypeName = "nvarchar(128)")]
|
||||
public string Comment { get; set; }
|
||||
|
||||
[Column("CONTRACT_TYPE")]
|
||||
public int? ContractType { get; set; }
|
||||
|
||||
#if NETFRAMEWORK
|
||||
[NotMapped]
|
||||
public string ContractTypeTranslated => My.Resources.Model.ResourceManager.GetString(ContractType.ToString());
|
||||
#endif
|
||||
|
||||
[Column("LANGUAGE", TypeName = "nvarchar(5)")]
|
||||
public string Language { get; set; }
|
||||
|
||||
[Column("SEND_REMINDER_EMAILS")]
|
||||
public bool SendReminderEmails { get; set; }
|
||||
|
||||
[Column("FIRST_REMINDER_DAYS")]
|
||||
public int? FirstReminderDays { get; set; }
|
||||
|
||||
[Column("REMINDER_INTERVAL_DAYS")]
|
||||
public int? ReminderIntervalDays { get; set; }
|
||||
|
||||
[Column("ENVELOPE_TYPE")]
|
||||
public int? EnvelopeTypeId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[NotMapped]
|
||||
public bool ReadOnly => EnvelopeTypeId == 2;
|
||||
|
||||
[Column("CERTIFICATION_TYPE")]
|
||||
public int? CertificationType { get; set; }
|
||||
|
||||
[Column("USE_ACCESS_CODE")]
|
||||
public bool UseAccessCode { get; set; }
|
||||
|
||||
[Column("FINAL_EMAIL_TO_CREATOR")]
|
||||
public int? FinalEmailToCreator { get; set; }
|
||||
|
||||
[Column("FINAL_EMAIL_TO_RECEIVERS")]
|
||||
public int? FinalEmailToReceivers { get; set; }
|
||||
|
||||
[Column("EXPIRES_WHEN_DAYS")]
|
||||
public int? ExpiresWhenDays { get; set; }
|
||||
|
||||
[Column("EXPIRES_WARNING_WHEN_DAYS")]
|
||||
public int? ExpiresWarningWhenDays { get; set; }
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
public User User { get; set; }
|
||||
|
||||
[Column("TFA_ENABLED")]
|
||||
public bool TfaEnabled { get; set; }
|
||||
#if NETFRAMEWORK
|
||||
= false;
|
||||
#endif
|
||||
|
||||
[NotMapped]
|
||||
[Column("DOC_RESULT")]
|
||||
public byte[]
|
||||
#if NET
|
||||
?
|
||||
#endif
|
||||
DocResult
|
||||
{ get; set; }
|
||||
|
||||
[ForeignKey("EnvelopeTypeId")]
|
||||
public virtual EnvelopeType
|
||||
#if NET
|
||||
?
|
||||
#endif
|
||||
Type { get; set; }
|
||||
|
||||
#if NETFRAMEWORK
|
||||
[NotMapped]
|
||||
public string CURRENT_WORK_APP { get; set; } = "signFLOW GUI";
|
||||
|
||||
[NotMapped]
|
||||
public bool IsAlreadySent => Status > EnvelopeStatus.EnvelopeSaved;
|
||||
#endif
|
||||
|
||||
public List<Document>
|
||||
#if NET
|
||||
?
|
||||
#endif
|
||||
Documents { get; set; }
|
||||
|
||||
public List<History>
|
||||
#if NET
|
||||
?
|
||||
#endif
|
||||
Histories { get; set; }
|
||||
|
||||
public List<EnvelopeReceiver>
|
||||
#if NET
|
||||
?
|
||||
#endif
|
||||
EnvelopeReceivers { get; set; }
|
||||
|
||||
//#if NETFRAMEWORK
|
||||
/// <summary>
|
||||
/// Validates whether the receiver and document data are complete.
|
||||
/// </summary>
|
||||
public List<string> ValidateReceiverDocumentData()
|
||||
{
|
||||
var errors = new List<string>();
|
||||
|
||||
if (!Documents?.Any() ?? true)
|
||||
errors.Add(My.Resources.Envelope.Missing_Documents);
|
||||
|
||||
if (!EnvelopeReceivers?.Any() ?? true)
|
||||
errors.Add(My.Resources.Envelope.Missing_Receivers);
|
||||
|
||||
if (EnvelopeReceivers?.Any(r => !r.HasEmailAndName) ?? false)
|
||||
errors.Add(My.Resources.Envelope.Incomplete_Receivers);
|
||||
|
||||
return errors;
|
||||
}
|
||||
//#endif
|
||||
}
|
||||
|
||||
#if NETFRAMEWORK
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,104 +1,94 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using DigitalData.Core.Abstractions.Interfaces;
|
||||
using EnvelopeGenerator.Domain.Interfaces;
|
||||
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
#endif
|
||||
using EnvelopeGenerator.Domain.Interfaces.Auditing;
|
||||
|
||||
namespace EnvelopeGenerator.Domain.Entities
|
||||
#if NET
|
||||
;
|
||||
#elif NETFRAMEWORK
|
||||
{
|
||||
#endif
|
||||
|
||||
[Table("TBSIG_ENVELOPE_RECEIVER", Schema = "dbo")]
|
||||
public class EnvelopeReceiver : IHasEnvelope, IHasReceiver, IEntity
|
||||
{
|
||||
public EnvelopeReceiver()
|
||||
[Table("TBSIG_ENVELOPE_RECEIVER", Schema = "dbo")]
|
||||
public class EnvelopeReceiver : IHasEnvelope, IHasReceiver, IEntity, IHasAddedWhen, IHasChangedWhen
|
||||
{
|
||||
public EnvelopeReceiver()
|
||||
{
|
||||
#if NETFRAMEWORK
|
||||
CompanyName = string.Empty;
|
||||
CompanyName = string.Empty;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
[Column("ENVELOPE_ID")]
|
||||
public int EnvelopeId { get; set; }
|
||||
[Column("ENVELOPE_ID")]
|
||||
public int EnvelopeId { get; set; }
|
||||
|
||||
[Column("RECEIVER_ID")]
|
||||
public int ReceiverId { get; set; }
|
||||
[Column("RECEIVER_ID")]
|
||||
public int ReceiverId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("SEQUENCE")]
|
||||
public int Sequence { get; set; }
|
||||
[Required]
|
||||
[Column("SEQUENCE")]
|
||||
public int Sequence { get; set; }
|
||||
|
||||
[Column("NAME", TypeName = "nvarchar(128)")]
|
||||
public string Name { get; set; }
|
||||
[Column("NAME", TypeName = "nvarchar(128)")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Column("JOB_TITLE", TypeName = "nvarchar(128)")]
|
||||
public string JobTitle { get; set; }
|
||||
[Column("JOB_TITLE", TypeName = "nvarchar(128)")]
|
||||
public string JobTitle { get; set; }
|
||||
|
||||
[Column("COMPANY_NAME", TypeName = "nvarchar(128)")]
|
||||
public string
|
||||
#if NET
|
||||
?
|
||||
[Column("COMPANY_NAME", TypeName = "nvarchar(128)")]
|
||||
public string
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
CompanyName { get; set; }
|
||||
CompanyName { get; set; }
|
||||
|
||||
[Column("PRIVATE_MESSAGE", TypeName = "nvarchar(max)")]
|
||||
public string PrivateMessage { get; set; }
|
||||
[Column("PRIVATE_MESSAGE", TypeName = "nvarchar(max)")]
|
||||
public string PrivateMessage { get; set; }
|
||||
|
||||
[Column("ACCESS_CODE", TypeName = "nvarchar(64)")]
|
||||
public string AccessCode { get; set; }
|
||||
[Column("ACCESS_CODE", TypeName = "nvarchar(64)")]
|
||||
public string AccessCode { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||
public DateTime AddedWhen { get; set; }
|
||||
[Required]
|
||||
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||
public DateTime AddedWhen { get; set; }
|
||||
|
||||
[Column("CHANGED_WHEN", TypeName = "datetime")]
|
||||
public DateTime ChangedWhen { get; set; }
|
||||
[Column("CHANGED_WHEN", TypeName = "datetime")]
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
|
||||
[Column("PHONE_NUMBER")]
|
||||
[StringLength(20)]
|
||||
[RegularExpression(@"^\+[0-9]+$", ErrorMessage = "Phone number must start with '+' followed by digits.")]
|
||||
public string PhoneNumber { get; set; }
|
||||
[Column("PHONE_NUMBER")]
|
||||
[StringLength(20)]
|
||||
[RegularExpression(@"^\+[0-9]+$", ErrorMessage = "Phone number must start with '+' followed by digits.")]
|
||||
public string PhoneNumber { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public Tuple<int, int> Id => Tuple.Create(EnvelopeId, ReceiverId);
|
||||
[NotMapped]
|
||||
public Tuple<int, int> Id => Tuple.Create(EnvelopeId, ReceiverId);
|
||||
|
||||
[NotMapped]
|
||||
public bool HasPhoneNumber => !string.IsNullOrWhiteSpace(PhoneNumber);
|
||||
[NotMapped]
|
||||
public bool HasPhoneNumber => !string.IsNullOrWhiteSpace(PhoneNumber);
|
||||
|
||||
[ForeignKey("EnvelopeId")]
|
||||
public Envelope
|
||||
#if NET
|
||||
?
|
||||
[ForeignKey("EnvelopeId")]
|
||||
public Envelope
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Envelope { get; set; }
|
||||
Envelope { get; set; }
|
||||
|
||||
[ForeignKey("ReceiverId")]
|
||||
public Receiver
|
||||
#if NET
|
||||
?
|
||||
[ForeignKey("ReceiverId")]
|
||||
public Receiver
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Receiver { get; set; }
|
||||
Receiver { get; set; }
|
||||
|
||||
#region Model of old serice
|
||||
[NotMapped]
|
||||
public Constants.ReceiverStatus Status { get; set; }
|
||||
#region Model of old serice
|
||||
[NotMapped]
|
||||
public Constants.ReceiverStatus Status { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public bool HasId => Id.Item1 > 0 && Id.Item2 > 0;
|
||||
[NotMapped]
|
||||
public bool HasId => Id.Item1 > 0 && Id.Item2 > 0;
|
||||
|
||||
[NotMapped]
|
||||
public bool HasEmailAndName =>
|
||||
!string.IsNullOrWhiteSpace(Receiver.EmailAddress) &&
|
||||
!string.IsNullOrWhiteSpace(Name);
|
||||
[NotMapped]
|
||||
public bool HasEmailAndName =>
|
||||
!string.IsNullOrWhiteSpace(Receiver.EmailAddress) &&
|
||||
!string.IsNullOrWhiteSpace(Name);
|
||||
#endregion
|
||||
}
|
||||
|
||||
#if NETFRAMEWORK
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,14 +1,13 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using DigitalData.EmailProfilerDispatcher.Abstraction.Attributes;
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
#endif
|
||||
using EnvelopeGenerator.Domain.Interfaces.Auditing;
|
||||
|
||||
namespace EnvelopeGenerator.Domain.Entities
|
||||
{
|
||||
[Table("TBSIG_ENVELOPE_RECEIVER_READ_ONLY")]
|
||||
public class EnvelopeReceiverReadOnly
|
||||
public class EnvelopeReceiverReadOnly : IHasChangedWhen, ICreationAuditable
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
@@ -42,16 +41,12 @@ namespace EnvelopeGenerator.Domain.Entities
|
||||
|
||||
[Column("ADDED_WHEN")]
|
||||
[Required]
|
||||
public DateTime
|
||||
#if NET
|
||||
?
|
||||
#endif
|
||||
AddedWhen { get; set; }
|
||||
public DateTime AddedWhen { get; set; }
|
||||
|
||||
[Column("CHANGED_WHO")]
|
||||
[StringLength(100)]
|
||||
public string
|
||||
#if NET
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
ChangedWho { get; set; }
|
||||
|
||||
@@ -1,84 +1,73 @@
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using System;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using EnvelopeGenerator.Domain.Interfaces;
|
||||
using EnvelopeGenerator.Domain.Constants;
|
||||
using DigitalData.Core.Abstractions.Interfaces;
|
||||
|
||||
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
#endif
|
||||
using EnvelopeGenerator.Domain.Interfaces.Auditing;
|
||||
|
||||
namespace EnvelopeGenerator.Domain.Entities
|
||||
#if NET
|
||||
;
|
||||
#elif NETFRAMEWORK
|
||||
{
|
||||
#endif
|
||||
|
||||
[Table("TBSIG_ENVELOPE_HISTORY", Schema = "dbo")]
|
||||
public class History : IHasEnvelope, IHasReceiver, IEntity
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("GUID")]
|
||||
public long Id { get; set; }
|
||||
[Table("TBSIG_ENVELOPE_HISTORY", Schema = "dbo")]
|
||||
public class History : IHasEnvelope, IHasReceiver, IEntity, IHasAddedWhen, IHasChangedWhen
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("GUID")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ENVELOPE_ID")]
|
||||
public int EnvelopeId { get; set; }
|
||||
[Required]
|
||||
[Column("ENVELOPE_ID")]
|
||||
public int EnvelopeId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("USER_REFERENCE", TypeName = "nvarchar(128)")]
|
||||
public string UserReference { get; set; }
|
||||
[Required]
|
||||
[Column("USER_REFERENCE", TypeName = "nvarchar(128)")]
|
||||
public string UserReference { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("STATUS")]
|
||||
public EnvelopeStatus Status { get; set; }
|
||||
[Required]
|
||||
[Column("STATUS")]
|
||||
public EnvelopeStatus Status { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
public DateTime AddedWhen { get; set; }
|
||||
[Required]
|
||||
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
public DateTime AddedWhen { get; set; }
|
||||
|
||||
[Column("ACTION_DATE", TypeName = "datetime")]
|
||||
public DateTime? ActionDate { get; set; } = DateTime.Now;
|
||||
|
||||
[Column("COMMENT", TypeName = "nvarchar(max)")]
|
||||
public string
|
||||
#if NET
|
||||
?
|
||||
[Column("ACTION_DATE", TypeName = "datetime")]
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
|
||||
[Column("COMMENT", TypeName = "nvarchar(max)")]
|
||||
public string
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Comment { get; set; }
|
||||
Comment { get; set; }
|
||||
|
||||
[ForeignKey("EnvelopeId")]
|
||||
public virtual Envelope
|
||||
#if NET
|
||||
?
|
||||
[ForeignKey("EnvelopeId")]
|
||||
public virtual Envelope
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Envelope { get; set; }
|
||||
Envelope { get; set; }
|
||||
|
||||
[ForeignKey("UserReference")]
|
||||
public virtual User
|
||||
#if NET
|
||||
?
|
||||
[ForeignKey("UserReference")]
|
||||
public virtual User
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Sender { get; set; }
|
||||
Sender { get; set; }
|
||||
|
||||
[ForeignKey("UserReference")]
|
||||
public virtual Receiver
|
||||
#if NET
|
||||
?
|
||||
[ForeignKey("UserReference")]
|
||||
public virtual Receiver
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Receiver { get; set; }
|
||||
Receiver { get; set; }
|
||||
|
||||
#if NETFRAMEWORK
|
||||
[NotMapped]
|
||||
public string StatusTranslated => My.Resources.Model.ResourceManager.GetString(Status.ToString());
|
||||
[NotMapped]
|
||||
public string StatusTranslated => My.Resources.Model.ResourceManager.GetString(Status.ToString());
|
||||
#endif
|
||||
}
|
||||
|
||||
#if NETFRAMEWORK
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,50 +1,42 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Drawing;
|
||||
using EnvelopeGenerator.Domain.Interfaces.Auditing;
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#endif
|
||||
|
||||
namespace EnvelopeGenerator.Domain.Entities
|
||||
#if NET
|
||||
;
|
||||
#elif NETFRAMEWORK
|
||||
{
|
||||
#endif
|
||||
|
||||
[Table("TBSIG_RECEIVER", Schema = "dbo")]
|
||||
public class Receiver
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("GUID")]
|
||||
public int Id { get; set; }
|
||||
[Table("TBSIG_RECEIVER", Schema = "dbo")]
|
||||
public class Receiver : IHasAddedWhen
|
||||
{
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("GUID")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required, EmailAddress]
|
||||
[Column("EMAIL_ADDRESS", TypeName = "nvarchar(250)")]
|
||||
[StringLength(250)]
|
||||
public string EmailAddress { get; set; }
|
||||
[Required, EmailAddress]
|
||||
[Column("EMAIL_ADDRESS", TypeName = "nvarchar(250)")]
|
||||
[StringLength(250)]
|
||||
public string EmailAddress { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("SIGNATURE", TypeName = "nvarchar(64)")]
|
||||
public string Signature { get; set; }
|
||||
[Required]
|
||||
[Column("SIGNATURE", TypeName = "nvarchar(64)")]
|
||||
public string Signature { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||
public DateTime AddedWhen { get; set; }
|
||||
[Required]
|
||||
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||
public DateTime AddedWhen { get; set; }
|
||||
|
||||
[Column("TOTP_SECRET_KEY", TypeName = "nvarchar(MAX)")]
|
||||
public string TotpSecretkey { get; set; }
|
||||
[Column("TOTP_SECRET_KEY", TypeName = "nvarchar(MAX)")]
|
||||
public string TotpSecretkey { get; set; }
|
||||
|
||||
[Column("TFA_REG_DEADLINE", TypeName = "datetime")]
|
||||
public DateTime? TfaRegDeadline { get; set; }
|
||||
[Column("TFA_REG_DEADLINE", TypeName = "datetime")]
|
||||
public DateTime? TfaRegDeadline { get; set; }
|
||||
|
||||
public List<EnvelopeReceiver> EnvelopeReceivers { get; set; }
|
||||
public List<EnvelopeReceiver> EnvelopeReceivers { get; set; }
|
||||
|
||||
public string GetSignature() => EmailAddress.ToUpperInvariant().GetChecksum();
|
||||
}
|
||||
|
||||
#if NETFRAMEWORK
|
||||
public string GetSignature() => EmailAddress.ToUpperInvariant().GetChecksum();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,134 +1,130 @@
|
||||
using EnvelopeGenerator.Domain.Interfaces;
|
||||
using System;
|
||||
using EnvelopeGenerator.Domain.Interfaces;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using EnvelopeGenerator.Domain.Interfaces.Auditing;
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#endif
|
||||
|
||||
namespace EnvelopeGenerator.Domain.Entities
|
||||
#if NET
|
||||
;
|
||||
#elif NETFRAMEWORK
|
||||
{
|
||||
#endif
|
||||
|
||||
[Table("TBSIG_DOCUMENT_RECEIVER_ELEMENT", Schema = "dbo")]
|
||||
public class Signature : ISignature, IHasReceiver
|
||||
{
|
||||
public Signature()
|
||||
[Table("TBSIG_DOCUMENT_RECEIVER_ELEMENT", Schema = "dbo")]
|
||||
public class Signature : ISignature, IHasReceiver, IHasAddedWhen, IUpdateAuditable
|
||||
{
|
||||
// TODO: * Check the Form App and remove the default value
|
||||
public Signature()
|
||||
{
|
||||
// TODO: * Check the Form App and remove the default value
|
||||
#if NETFRAMEWORK
|
||||
Id = -1;
|
||||
Required = false;
|
||||
ReadOnly = false;
|
||||
AnnotationIndex = 0;
|
||||
Id = -1;
|
||||
Required = false;
|
||||
ReadOnly = false;
|
||||
AnnotationIndex = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("GUID")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("DOCUMENT_ID")]
|
||||
public int DocumentId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("RECEIVER_ID")]
|
||||
public int ReceiverId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ELEMENT_TYPE")]
|
||||
[DefaultValue(0)]
|
||||
public int ElementType { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("POSITION_X")]
|
||||
[DefaultValue(0)]
|
||||
public double X { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("POSITION_Y")]
|
||||
[DefaultValue(0)]
|
||||
public double Y { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("WIDTH")]
|
||||
[DefaultValue(0)]
|
||||
public double Width { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("HEIGHT")]
|
||||
[DefaultValue(0)]
|
||||
public double Height { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("PAGE")]
|
||||
[DefaultValue(1)]
|
||||
public int Page { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("REQUIRED")]
|
||||
[DefaultValue(false)]
|
||||
public bool Required { get; set; }
|
||||
|
||||
[Column("TOOLTIP")]
|
||||
public string Tooltip { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("READ_ONLY")]
|
||||
[DefaultValue(false)]
|
||||
public bool ReadOnly { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ANNOTATION_INDEX")]
|
||||
[DefaultValue(0)]
|
||||
public int AnnotationIndex { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||
[DefaultValue("GETDATE()")]
|
||||
public DateTime AddedWhen { get; set; }
|
||||
|
||||
[Column("CHANGED_WHEN", TypeName = "datetime")]
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
|
||||
[Column("CHANGED_WHO", TypeName = "nvarchar(100)")]
|
||||
public string
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
ChangedWho
|
||||
{ get; set; }
|
||||
|
||||
[ForeignKey("DocumentId")]
|
||||
public virtual Document Document { get; set; }
|
||||
|
||||
[ForeignKey("ReceiverId")]
|
||||
public virtual Receiver
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Receiver
|
||||
{ get; set; }
|
||||
|
||||
public virtual IEnumerable<ElementAnnotation>
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Annotations
|
||||
{ get; set; }
|
||||
|
||||
#if NETFRAMEWORK
|
||||
[NotMapped]
|
||||
public double Top => Math.Round(Y, 5);
|
||||
|
||||
[NotMapped]
|
||||
public double Left => Math.Round(X, 5);
|
||||
#endif
|
||||
}
|
||||
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Column("GUID")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("DOCUMENT_ID")]
|
||||
public int DocumentId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("RECEIVER_ID")]
|
||||
public int ReceiverId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ELEMENT_TYPE")]
|
||||
[DefaultValue(0)]
|
||||
public int ElementType { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("POSITION_X")]
|
||||
[DefaultValue(0)]
|
||||
public double X { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("POSITION_Y")]
|
||||
[DefaultValue(0)]
|
||||
public double Y { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("WIDTH")]
|
||||
[DefaultValue(0)]
|
||||
public double Width { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("HEIGHT")]
|
||||
[DefaultValue(0)]
|
||||
public double Height { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("PAGE")]
|
||||
[DefaultValue(1)]
|
||||
public int Page { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("REQUIRED")]
|
||||
[DefaultValue(false)]
|
||||
public bool Required { get; set; }
|
||||
|
||||
[Column("TOOLTIP")]
|
||||
public string Tooltip { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("READ_ONLY")]
|
||||
[DefaultValue(false)]
|
||||
public bool ReadOnly { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ANNOTATION_INDEX")]
|
||||
[DefaultValue(0)]
|
||||
public int AnnotationIndex { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||
[DefaultValue("GETDATE()")]
|
||||
public DateTime? AddedWhen { get; set; }
|
||||
|
||||
[Column("CHANGED_WHEN", TypeName = "datetime")]
|
||||
public DateTime? ChangedWhen { get; set; }
|
||||
|
||||
[Column("CHANGED_WHO", TypeName = "nvarchar(100)")]
|
||||
public string
|
||||
#if NET
|
||||
?
|
||||
#endif
|
||||
ChangedWho { get; set; }
|
||||
|
||||
[ForeignKey("DocumentId")]
|
||||
public virtual Document Document { get; set; }
|
||||
|
||||
[ForeignKey("ReceiverId")]
|
||||
public virtual Receiver
|
||||
#if NET
|
||||
?
|
||||
#endif
|
||||
Receiver { get; set; }
|
||||
|
||||
public virtual IEnumerable<ElementAnnotation>
|
||||
#if NET
|
||||
?
|
||||
#endif
|
||||
Annotations { get; set; }
|
||||
|
||||
#if NETFRAMEWORK
|
||||
[NotMapped]
|
||||
public double Top => Math.Round(Y, 5);
|
||||
|
||||
[NotMapped]
|
||||
public double Left => Math.Round(X, 5);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if NETFRAMEWORK
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace EnvelopeGenerator.Domain.Interfaces.Auditing
|
||||
{
|
||||
public interface ICreationAuditable : IHasAddedWhen, IHasAddedWho
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
#endif
|
||||
|
||||
namespace EnvelopeGenerator.Domain.Interfaces.Auditing
|
||||
{
|
||||
public interface IHasAddedWhen
|
||||
{
|
||||
DateTime AddedWhen { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace EnvelopeGenerator.Domain.Interfaces.Auditing
|
||||
{
|
||||
public interface IHasAddedWho
|
||||
{
|
||||
string AddedWho { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
#endif
|
||||
|
||||
namespace EnvelopeGenerator.Domain.Interfaces.Auditing
|
||||
{
|
||||
public interface IHasChangedWhen
|
||||
{
|
||||
DateTime? ChangedWhen { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace EnvelopeGenerator.Domain.Interfaces.Auditing
|
||||
{
|
||||
public interface IHasChangedWho
|
||||
{
|
||||
string
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
ChangedWho { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace EnvelopeGenerator.Domain.Interfaces.Auditing
|
||||
{
|
||||
public interface IUpdateAuditable : IHasChangedWhen, IHasChangedWho
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,11 @@
|
||||
namespace EnvelopeGenerator.Domain.Interfaces
|
||||
#if NET
|
||||
;
|
||||
#elif NETFRAMEWORK
|
||||
{
|
||||
#endif
|
||||
|
||||
public interface IHasEnvelope
|
||||
{
|
||||
#if NET
|
||||
public
|
||||
#endif
|
||||
public interface IHasEnvelope
|
||||
{
|
||||
Entities.Envelope
|
||||
#if NET
|
||||
?
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Envelope { get; set; }
|
||||
}
|
||||
|
||||
#if NETFRAMEWORK
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,11 @@
|
||||
namespace EnvelopeGenerator.Domain.Interfaces
|
||||
#if NET
|
||||
;
|
||||
#elif NETFRAMEWORK
|
||||
{
|
||||
public interface IHasReceiver
|
||||
{
|
||||
#endif
|
||||
|
||||
public interface IHasReceiver
|
||||
{
|
||||
#if NET
|
||||
public
|
||||
#endif
|
||||
Entities.Receiver
|
||||
#if NET
|
||||
?
|
||||
#if nullable
|
||||
?
|
||||
#endif
|
||||
Receiver { get; set; }
|
||||
}
|
||||
|
||||
#if NETFRAMEWORK
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Web.Controllers;
|
||||
|
||||
[Authorize(Roles = Role.FullyAuth)]
|
||||
[Authorize(Roles = Role.ReceiverFull)]
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class AnnotationController : ControllerBase
|
||||
@@ -42,7 +42,7 @@ public class AnnotationController : ControllerBase
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[Authorize(Roles = Role.FullyAuth)]
|
||||
[Authorize(Roles = Role.ReceiverFull)]
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> CreateOrUpdate([FromBody] PsPdfKitAnnotation? psPdfKitAnnotation = null, CancellationToken cancel = default)
|
||||
{
|
||||
@@ -80,7 +80,7 @@ public class AnnotationController : ControllerBase
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[Authorize(Roles = Role.FullyAuth)]
|
||||
[Authorize(Roles = Role.ReceiverFull)]
|
||||
[HttpPost("reject")]
|
||||
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
|
||||
public async Task<IActionResult> Reject([FromBody] string? reason = null)
|
||||
|
||||
@@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace EnvelopeGenerator.Web.Controllers;
|
||||
|
||||
[Authorize(Roles = Role.FullyAuth)]
|
||||
[Authorize(Roles = Role.ReceiverFull)]
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class DocumentController : ControllerBase
|
||||
|
||||
@@ -107,7 +107,7 @@ public class EnvelopeController : ViewControllerBase
|
||||
return this.ViewEnvelopeNotFound();
|
||||
}
|
||||
var er_secret = er_secret_res.Data;
|
||||
await HttpContext.SignInEnvelopeAsync(er_secret, Role.FullyAuth);
|
||||
await HttpContext.SignInEnvelopeAsync(er_secret, Role.ReceiverFull);
|
||||
return await CreateShowEnvelopeView(er_secret);
|
||||
}
|
||||
#endregion UseAccessCode
|
||||
@@ -172,7 +172,7 @@ public class EnvelopeController : ViewControllerBase
|
||||
}
|
||||
|
||||
// show envelope if already logged in
|
||||
if (User.IsInRole(Role.FullyAuth))
|
||||
if (User.IsInRole(Role.ReceiverFull))
|
||||
return await CreateShowEnvelopeView(er_secret);
|
||||
|
||||
if (auth.HasMulti)
|
||||
@@ -206,7 +206,7 @@ public class EnvelopeController : ViewControllerBase
|
||||
.WithData("ErrorMessage", _localizer.WrongEnvelopeReceiverId());
|
||||
}
|
||||
|
||||
await HttpContext.SignInEnvelopeAsync(er_secret, Role.FullyAuth);
|
||||
await HttpContext.SignInEnvelopeAsync(er_secret, Role.ReceiverFull);
|
||||
|
||||
return await CreateShowEnvelopeView(er_secret);
|
||||
}
|
||||
@@ -225,9 +225,9 @@ public class EnvelopeController : ViewControllerBase
|
||||
&& uuidClaim == er.Envelope?.Uuid
|
||||
&& signatureClaim is not null
|
||||
&& signatureClaim == er.Receiver?.Signature
|
||||
&& User.IsInRole(Role.FullyAuth))
|
||||
&& User.IsInRole(Role.ReceiverFull))
|
||||
{
|
||||
await HttpContext.SignInEnvelopeAsync(er, Role.FullyAuth);
|
||||
await HttpContext.SignInEnvelopeAsync(er, Role.ReceiverFull);
|
||||
|
||||
//add PSPDFKit licence key
|
||||
ViewData["PSPDFKitLicenseKey"] = _configuration["PSPDFKitLicenseKey"];
|
||||
@@ -262,7 +262,7 @@ public class EnvelopeController : ViewControllerBase
|
||||
return this.ViewDocumentNotFound();
|
||||
}
|
||||
|
||||
await HttpContext.SignInEnvelopeAsync(er, Role.FullyAuth);
|
||||
await HttpContext.SignInEnvelopeAsync(er, Role.ReceiverFull);
|
||||
|
||||
ViewData["ReadAndConfirm"] = er.Envelope.ReadOnly;
|
||||
|
||||
@@ -334,7 +334,7 @@ public class EnvelopeController : ViewControllerBase
|
||||
await _rcvService.UpdateAsync(rcv);
|
||||
}
|
||||
|
||||
await HttpContext.SignInEnvelopeAsync(er_secret, Role.PreAuth);
|
||||
await HttpContext.SignInEnvelopeAsync(er_secret, Role.ReceiverTFA);
|
||||
|
||||
return await TFAViewAsync(auth.UserSelectSMS, er_secret, envelopeReceiverId);
|
||||
}
|
||||
@@ -348,7 +348,7 @@ public class EnvelopeController : ViewControllerBase
|
||||
if (er_secret.Receiver!.TotpSecretkey is null)
|
||||
throw new InvalidOperationException($"TotpSecretkey of DTO cannot validate without TotpSecretkey. Dto: {JsonConvert.SerializeObject(er_secret)}");
|
||||
|
||||
if (!User.IsInRole(Role.PreAuth) || !_envSmsHandler.VerifyTotp(auth.SmsCode!, er_secret.Receiver.TotpSecretkey))
|
||||
if (!User.IsInRole(Role.ReceiverTFA) || !_envSmsHandler.VerifyTotp(auth.SmsCode!, er_secret.Receiver.TotpSecretkey))
|
||||
{
|
||||
Response.StatusCode = StatusCodes.Status401Unauthorized;
|
||||
ViewData["ErrorMessage"] = _localizer.WrongAccessCode();
|
||||
@@ -364,7 +364,7 @@ public class EnvelopeController : ViewControllerBase
|
||||
if (er_secret.Receiver!.TotpSecretkey is null)
|
||||
throw new InvalidOperationException($"TotpSecretkey of DTO cannot validate without TotpSecretkey. Dto: {JsonConvert.SerializeObject(er_secret)}");
|
||||
|
||||
if (!User.IsInRole(Role.PreAuth) || !_authenticator.VerifyTotp(auth.AuthenticatorCode!, er_secret.Receiver.TotpSecretkey, window: VerificationWindow.RfcSpecifiedNetworkDelay))
|
||||
if (!User.IsInRole(Role.ReceiverTFA) || !_authenticator.VerifyTotp(auth.AuthenticatorCode!, er_secret.Receiver.TotpSecretkey, window: VerificationWindow.RfcSpecifiedNetworkDelay))
|
||||
{
|
||||
Response.StatusCode = StatusCodes.Status401Unauthorized;
|
||||
ViewData["ErrorMessage"] = _localizer.WrongAccessCode();
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace EnvelopeGenerator.Web.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize(Roles = Role.FullyAuth)]
|
||||
[Authorize(Roles = Role.ReceiverFull)]
|
||||
[Obsolete("Use MediatR")]
|
||||
public async Task<IActionResult> CreateAsync([FromBody] EnvelopeReceiverReadOnlyCreateDto createDto)
|
||||
{
|
||||
|
||||
@@ -91,7 +91,7 @@ public class TFARegController : ViewControllerBase
|
||||
}
|
||||
}
|
||||
|
||||
[Authorize(Roles = Role.FullyAuth)]
|
||||
[Authorize(Roles = Role.ReceiverFull)]
|
||||
[HttpPost("auth/logout")]
|
||||
public async Task<IActionResult> LogOut()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user