Compare commits

...

2 Commits

Author SHA1 Message Date
Developer 02
cbb03d77ba Animierte Navbar-Anzeige für envelopeDto-Informationen hinzugefügt 2024-04-04 17:35:43 +02:00
Developer 02
29ae546d98 EF Core Beziehungskonfiguration für Envelope-Entität korrigiert 2024-04-04 13:25:41 +02:00
33 changed files with 384 additions and 107 deletions

View File

@@ -7,5 +7,8 @@ namespace EnvelopeGenerator.Application.Contracts
{ {
public interface IEnvelopeService : IBasicCRUDService<IEnvelopeRepository, EnvelopeDto, Envelope, int> public interface IEnvelopeService : IBasicCRUDService<IEnvelopeRepository, EnvelopeDto, Envelope, int>
{ {
Task<IServiceResult<IEnumerable<EnvelopeDto>>> ReadAllWithAsync(bool documents = false, bool receivers = false, bool history = false);
Task<IServiceResult<EnvelopeDto>> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withReceivers = false, bool withHistory = false);
} }
} }

View File

@@ -1,7 +1,7 @@
namespace EnvelopeGenerator.Application.DTOs namespace EnvelopeGenerator.Application.DTOs
{ {
public record DocumentReceiverElementDto( public record DocumentReceiverElementDto(
int Guid, int Id,
int DocumentId, int DocumentId,
int ReceiverId, int ReceiverId,
int ElementType, int ElementType,
@@ -17,5 +17,7 @@
DateTime AddedWhen, DateTime AddedWhen,
DateTime? ChangedWhen, DateTime? ChangedWhen,
EnvelopeDocumentDto? Document, EnvelopeDocumentDto? Document,
EnvelopeReceiverDto? Receiver); EnvelopeReceiverDto? Receiver,
double Top,
double Left);
} }

View File

@@ -1,7 +1,7 @@
namespace EnvelopeGenerator.Application.DTOs namespace EnvelopeGenerator.Application.DTOs
{ {
public record DocumentStatusDto( public record DocumentStatusDto(
int Guid, int Id,
int EnvelopeId, int EnvelopeId,
int ReceiverId, int ReceiverId,
int Status, int Status,

View File

@@ -1,7 +1,7 @@
namespace EnvelopeGenerator.Application.DTOs namespace EnvelopeGenerator.Application.DTOs
{ {
public record EmailTemplateDto( public record EmailTemplateDto(
int Guid, int Id,
string Name, string Name,
string Body, string Body,
string Subject); string Subject);

View File

@@ -1,7 +1,7 @@
namespace EnvelopeGenerator.Application.DTOs namespace EnvelopeGenerator.Application.DTOs
{ {
public record EnvelopeCertificateDto( public record EnvelopeCertificateDto(
int Guid, int Id,
int EnvelopeId, int EnvelopeId,
string EnvelopeUuid, string EnvelopeUuid,
string EnvelopeSubject, string EnvelopeSubject,

View File

@@ -1,12 +1,15 @@
namespace EnvelopeGenerator.Application.DTOs using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Application.DTOs
{ {
public record EnvelopeDocumentDto public record EnvelopeDocumentDto
{ (
public int Guid { get; init; } int Id,
public int EnvelopeId { get; init; } int EnvelopeId,
public string Filename { get; init; } string Filename,
public string Filepath { get; init; } string Filepath,
public DateTime AddedWhen { get; init; } DateTime AddedWhen,
public string FilenameOriginal { get; init; } string FilenameOriginal,
} ICollection<DocumentReceiverElement>? Elements
);
} }

View File

@@ -1,10 +1,12 @@
namespace EnvelopeGenerator.Application.DTOs using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Application.DTOs
{ {
public record EnvelopeDto( public record EnvelopeDto(
int Guid, int Id,
int UserId, int UserId,
int Status, int Status,
string EnvelopeUuid, string Uuid,
string Message, string Message,
DateTime? ExpiresWhen, DateTime? ExpiresWhen,
DateTime? ExpiresWarningWhen, DateTime? ExpiresWarningWhen,
@@ -16,12 +18,21 @@
bool? SendReminderEmails, bool? SendReminderEmails,
int? FirstReminderDays, int? FirstReminderDays,
int? ReminderIntervalDays, int? ReminderIntervalDays,
int? EnvelopeType, int? EnvelopeTypeId,
int? CertificationType, int? CertificationType,
bool? UseAccessCode, bool? UseAccessCode,
int? FinalEmailToCreator, int? FinalEmailToCreator,
int? FinalEmailToReceivers, int? FinalEmailToReceivers,
int? ExpiresWhenDays, int? ExpiresWhenDays,
int? ExpiresWarningWhenDays, int? ExpiresWarningWhenDays,
bool DmzMoved); bool DmzMoved,
ReceiverDto? User,
EnvelopeType? EnvelopeType,
string? EnvelopeTypeTitle,
bool IsAlreadySent,
string? StatusTranslated,
string? ContractTypeTranslated,
ICollection<EnvelopeDocument>? Documents,
ICollection<EnvelopeReceiver>? Receivers,
ICollection<EnvelopeHistory>? History);
} }

View File

@@ -1,7 +1,7 @@
namespace EnvelopeGenerator.Application.DTOs namespace EnvelopeGenerator.Application.DTOs
{ {
public record EnvelopeHistoryDto( public record EnvelopeHistoryDto(
long Guid, long Id,
int EnvelopeId, int EnvelopeId,
string UserReference, string UserReference,
int Status, int Status,

View File

@@ -1,7 +1,7 @@
namespace EnvelopeGenerator.Application.DTOs namespace EnvelopeGenerator.Application.DTOs
{ {
public record EnvelopeTypeDto( public record EnvelopeTypeDto(
int Guid, int Id,
string Title, string Title,
string Language, string Language,
int? ExpiresDays, int? ExpiresDays,

View File

@@ -1,7 +1,7 @@
namespace EnvelopeGenerator.Application.DTOs namespace EnvelopeGenerator.Application.DTOs
{ {
public record ReceiverDto( public record ReceiverDto(
int Guid, int Id,
string EmailAddress, string EmailAddress,
string Signature, string Signature,
DateTime AddedWhen); DateTime AddedWhen);

View File

@@ -1,7 +1,7 @@
namespace EnvelopeGenerator.Application.DTOs namespace EnvelopeGenerator.Application.DTOs
{ {
public record UserReceiverDto( public record UserReceiverDto(
int Guid, int Id,
int UserId, int UserId,
int ReceiverId, int ReceiverId,
string Name, string Name,

View File

@@ -1,5 +1,6 @@
using AutoMapper; using AutoMapper;
using DigitalData.Core.Application; using DigitalData.Core.Application;
using DigitalData.Core.Contracts.Application;
using DigitalData.Core.Contracts.CultureServices; using DigitalData.Core.Contracts.CultureServices;
using EnvelopeGenerator.Application.Contracts; using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Application.DTOs;
@@ -14,5 +15,23 @@ namespace EnvelopeGenerator.Application.Services
: base(repository, translationService, mapper) : base(repository, translationService, mapper)
{ {
} }
public async Task<IServiceResult<IEnumerable<EnvelopeDto>>> ReadAllWithAsync(bool documents = false, bool receivers = false, bool history = false)
{
var envelopes = await _repository.ReadAllWithAsync(documents: documents, receivers: receivers, history: history);
var readDto = _mapper.MapOrThrow<IEnumerable<EnvelopeDto>>(envelopes);
return Successful(readDto);
}
public async Task<IServiceResult<EnvelopeDto>> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withReceivers = false, bool withHistory = false)
{
var envelope = await _repository.ReadByUuidAsync(uuid: uuid, withDocuments: withDocuments, withReceivers: withReceivers, withHistory: withHistory);
if (envelope is null)
return Failed<EnvelopeDto>();
var readDto = _mapper.MapOrThrow<EnvelopeDto>(envelope);
return Successful(readDto);
}
} }
} }

View File

@@ -0,0 +1,119 @@
namespace EnvelopeGenerator.Domain
{
public class Constants
{
#region Status Fields
public enum EnvelopeStatus
{
Invalid = 0,
EnvelopeCreated = 1001,
EnvelopeSaved = 1002,
EnvelopeQueued = 1003,
EnvelopeSent = 1004, // Not used
EnvelopePartlySigned = 1005,
EnvelopeCompletelySigned = 1006,
EnvelopeReportCreated = 1007,
EnvelopeArchived = 1008,
EnvelopeDeleted = 1009,
AccessCodeRequested = 2001,
AccessCodeCorrect = 2002,
AccessCodeIncorrect = 2003,
DocumentOpened = 2004,
DocumentSigned = 2005,
SignatureConfirmed = 2006,
MessageInvitationSent = 3001, // Used by Trigger
MessageAccessCodeSent = 3002,
MessageConfirmationSent = 3003,
MessageDeletionSent = 3004,
MessageCompletionSent = 3005
}
public enum ElementStatus
{
Created = 0
}
public enum DocumentStatus
{
Created = 0,
Signed = 1
}
public enum ReceiverStatus
{
Unsigned = 0,
Signed = 1
}
#endregion
#region Type Fields
public enum ElementType
{
Signature = 1
}
public enum ContractType
{
Contract = 1,
ReadAndSign = 2
}
public enum ColorType
{
ReceiverColor1 = 1,
ReceiverColor2 = 2,
ReceiverColor3 = 3,
ReceiverColor4 = 4,
ReceiverColor5 = 5,
ReceiverColor6 = 6,
ReceiverColor7 = 7,
ReceiverColor8 = 8,
ReceiverColor9 = 9,
ReceiverColor10 = 10
}
public enum CertificationType
{
ElectronicSignature = 1,
QualifiedSignature = 2
}
public enum FinalEmailType
{
No = 0,
Yes = 1,
YesWithAttachment = 2
}
public enum PageOrientation
{
Portrait = 0,
Landscape = 1
}
public enum EmailTemplateType
{
DocumentReceived,
DocumentSigned,
DocumentDeleted,
DocumentCompleted,
DocumentAccessCodeReceived
}
#endregion
#region Constants
public const string DATABASE = "DATABASE";
public const string LOGCONFIG = "LOGCONFIG";
public const string GDPICTURE = "GDPICTURE";
public const string GREEN_300 = "#bbf7d0";
public const string RED_300 = "#fecaca";
public const string ORANGE_300 = "#fed7aa";
#endregion
}
}

View File

@@ -10,7 +10,7 @@ namespace EnvelopeGenerator.Domain.Entities
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")] [Column("GUID")]
public int Guid { get; set; } public int Id { get; set; }
[Required] [Required]
[Column("DOCUMENT_ID")] [Column("DOCUMENT_ID")]
@@ -28,12 +28,12 @@ namespace EnvelopeGenerator.Domain.Entities
[Required] [Required]
[Column("POSITION_X")] [Column("POSITION_X")]
[DefaultValue(0)] [DefaultValue(0)]
public double PositionX { get; set; } public double X { get; set; }
[Required] [Required]
[Column("POSITION_Y")] [Column("POSITION_Y")]
[DefaultValue(0)] [DefaultValue(0)]
public double PositionY { get; set; } public double Y { get; set; }
[Required] [Required]
[Column("WIDTH")] [Column("WIDTH")]
@@ -81,5 +81,11 @@ namespace EnvelopeGenerator.Domain.Entities
[ForeignKey("ReceiverId")] [ForeignKey("ReceiverId")]
public virtual Receiver? Receiver { get; set; } public virtual Receiver? Receiver { get; set; }
[NotMapped]
public double Top => Math.Round(Y, 5);
[NotMapped]
public double Left => Math.Round(X, 5);
} }
} }

View File

@@ -9,7 +9,7 @@ namespace EnvelopeGenerator.Domain.Entities
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")] [Column("GUID")]
public int Guid { get; set; } public int Id { get; set; }
[Required] [Required]
[Column("ENVELOPE_ID")] [Column("ENVELOPE_ID")]

View File

@@ -9,7 +9,7 @@ namespace EnvelopeGenerator.Domain.Entities
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")] [Column("GUID")]
public int Guid { get; set; } public int Id { get; set; }
[Column("NAME", TypeName = "nvarchar(64)")] [Column("NAME", TypeName = "nvarchar(64)")]
public string Name { get; set; } public string Name { get; set; }

View File

@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations; using EnvelopeGenerator.Common.My.Resources;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
namespace EnvelopeGenerator.Domain.Entities namespace EnvelopeGenerator.Domain.Entities
@@ -9,7 +10,7 @@ namespace EnvelopeGenerator.Domain.Entities
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")] [Column("GUID")]
public int Guid { get; set; } public int Id { get; set; }
[Required] [Required]
[Column("USER_ID")] [Column("USER_ID")]
@@ -21,7 +22,7 @@ namespace EnvelopeGenerator.Domain.Entities
[Required] [Required]
[Column("ENVELOPE_UUID", TypeName = "nvarchar(36)")] [Column("ENVELOPE_UUID", TypeName = "nvarchar(36)")]
public string EnvelopeUuid { get; set; } public string Uuid { get; set; }
[Required] [Required]
[Column("MESSAGE", TypeName = "nvarchar(max)")] [Column("MESSAGE", TypeName = "nvarchar(max)")]
@@ -59,7 +60,7 @@ namespace EnvelopeGenerator.Domain.Entities
public int? ReminderIntervalDays { get; set; } public int? ReminderIntervalDays { get; set; }
[Column("ENVELOPE_TYPE")] [Column("ENVELOPE_TYPE")]
public int? EnvelopeType { get; set; } public int? EnvelopeTypeId { get; set; }
[Column("CERTIFICATION_TYPE")] [Column("CERTIFICATION_TYPE")]
public int? CertificationType { get; set; } public int? CertificationType { get; set; }
@@ -82,5 +83,36 @@ namespace EnvelopeGenerator.Domain.Entities
[Required] [Required]
[Column("DMZ_MOVED")] [Column("DMZ_MOVED")]
public bool DmzMoved { get; set; } public bool DmzMoved { get; set; }
[ForeignKey("UserId")]
public Receiver? User { get; set; }
[ForeignKey("EnvelopeTypeId")]
public EnvelopeType? EnvelopeType { get; set; }
[NotMapped]
public string? EnvelopeTypeTitle => EnvelopeType?.Title;
[NotMapped]
public bool IsAlreadySent => Status > (int) Constants.EnvelopeStatus.EnvelopeSaved;
[NotMapped]
public string? StatusTranslated => Model.ResourceManager.GetString(Status.ToString());
[NotMapped]
public string? ContractTypeTranslated
{
get
{
string? oContractType = ContractType.ToString();
return oContractType is null ? default : Model.ResourceManager.GetString(oContractType);
}
}
public ICollection<EnvelopeDocument>? Documents { get; set; }
public ICollection<EnvelopeReceiver>? Receivers { get; set; }
public ICollection<EnvelopeHistory>? History { get; set; }
} }
} }

View File

@@ -9,7 +9,7 @@ namespace EnvelopeGenerator.Domain.Entities
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")] [Column("GUID")]
public int Guid { get; set; } public int Id { get; set; }
[Required] [Required]
[Column("ENVELOPE_ID")] [Column("ENVELOPE_ID")]

View File

@@ -9,7 +9,7 @@ namespace EnvelopeGenerator.Domain.Entities
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")] [Column("GUID")]
public int Guid { get; set; } public int Id { get; set; }
[Required] [Required]
[Column("ENVELOPE_ID")] [Column("ENVELOPE_ID")]
@@ -29,5 +29,7 @@ namespace EnvelopeGenerator.Domain.Entities
[Column("FILENAME_ORIGINAL", TypeName = "nvarchar(256)")] [Column("FILENAME_ORIGINAL", TypeName = "nvarchar(256)")]
public string FilenameOriginal { get; set; } public string FilenameOriginal { get; set; }
public ICollection<DocumentReceiverElement>? Elements { get; set; }
} }
} }

View File

@@ -9,7 +9,7 @@ namespace EnvelopeGenerator.Domain.Entities
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")] [Column("GUID")]
public long Guid { get; set; } public long Id { get; set; }
[Required] [Required]
[Column("ENVELOPE_ID")] [Column("ENVELOPE_ID")]

View File

@@ -6,7 +6,6 @@ namespace EnvelopeGenerator.Domain.Entities
[Table("TBSIG_ENVELOPE_RECEIVER", Schema = "dbo")] [Table("TBSIG_ENVELOPE_RECEIVER", Schema = "dbo")]
public class EnvelopeReceiver public class EnvelopeReceiver
{ {
[Column("ENVELOPE_ID")] [Column("ENVELOPE_ID")]
public int EnvelopeId { get; set; } public int EnvelopeId { get; set; }

View File

@@ -11,7 +11,7 @@ namespace EnvelopeGenerator.Domain.Entities
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")] [Column("GUID")]
public int Guid { get; set; } public int Id { get; set; }
[Required] [Required]
[Column("TITLE", TypeName = "nvarchar(128)")] [Column("TITLE", TypeName = "nvarchar(128)")]

View File

@@ -9,7 +9,7 @@ namespace EnvelopeGenerator.Domain.Entities
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")] [Column("GUID")]
public int Guid { get; set; } public int Id { get; set; }
[Required] [Required]
[Column("EMAIL_ADDRESS", TypeName = "nvarchar(128)")] [Column("EMAIL_ADDRESS", TypeName = "nvarchar(128)")]

View File

@@ -1,7 +1,5 @@
using System; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Domain.Entities namespace EnvelopeGenerator.Domain.Entities
{ {
@@ -11,7 +9,7 @@ namespace EnvelopeGenerator.Domain.Entities
[Key] [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)] [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")] [Column("GUID")]
public int Guid { get; set; } public int Id { get; set; }
[Required] [Required]
[Column("USER_ID")] [Column("USER_ID")]

View File

@@ -6,4 +6,8 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\EnvelopeGenerator.Common\EnvelopeGenerator.Common.vbproj" />
</ItemGroup>
</Project> </Project>

View File

@@ -5,5 +5,8 @@ namespace EnvelopeGenerator.Infrastructure.Contracts
{ {
public interface IEnvelopeRepository : ICRUDRepository<Envelope, int> public interface IEnvelopeRepository : ICRUDRepository<Envelope, int>
{ {
Task<IEnumerable<Envelope>> ReadAllWithAsync(bool documents = false, bool receivers = false, bool history = false);
Task<Envelope?> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withReceivers = false, bool withHistory = false);
} }
} }

View File

@@ -13,7 +13,8 @@ namespace DigitalData.UserManager.Infrastructure.Repositories
{ {
modelBuilder.Entity<Config>().HasNoKey(); modelBuilder.Entity<Config>().HasNoKey();
modelBuilder.Entity<EnvelopeReceiver>().HasNoKey(); modelBuilder.Entity<EnvelopeReceiver>()
.HasKey(er => new { er.EnvelopeId, er.ReceiverId });
modelBuilder.Entity<EnvelopeDocument>(); modelBuilder.Entity<EnvelopeDocument>();
modelBuilder.Entity<DocumentReceiverElement>(); modelBuilder.Entity<DocumentReceiverElement>();
@@ -26,6 +27,22 @@ namespace DigitalData.UserManager.Infrastructure.Repositories
modelBuilder.Entity<Receiver>(); modelBuilder.Entity<Receiver>();
modelBuilder.Entity<UserReceiver>(); modelBuilder.Entity<UserReceiver>();
// Configure the one-to-many relationship of Envelope
modelBuilder.Entity<Envelope>()
.HasMany(e => e.Documents)
.WithOne()
.HasForeignKey(ed => ed.EnvelopeId);
modelBuilder.Entity<Envelope>()
.HasMany(e => e.Receivers)
.WithOne()
.HasForeignKey(er => er.EnvelopeId);
modelBuilder.Entity<Envelope>()
.HasMany(e => e.History)
.WithOne()
.HasForeignKey(eh => eh.EnvelopeId);
base.OnModelCreating(modelBuilder); base.OnModelCreating(modelBuilder);
} }
} }

View File

@@ -2,6 +2,7 @@
using DigitalData.UserManager.Infrastructure.Repositories; using DigitalData.UserManager.Infrastructure.Repositories;
using EnvelopeGenerator.Domain.Entities; using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts; using EnvelopeGenerator.Infrastructure.Contracts;
using Microsoft.EntityFrameworkCore;
namespace EnvelopeGenerator.Infrastructure.Repositories namespace EnvelopeGenerator.Infrastructure.Repositories
{ {
@@ -10,5 +11,37 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
public EnvelopeRepository(EGDbContext dbContext) : base(dbContext) public EnvelopeRepository(EGDbContext dbContext) : base(dbContext)
{ {
} }
public async Task<IEnumerable<Envelope>> ReadAllWithAsync(bool documents = false, bool receivers = false, bool history = false)
{
var query = _dbSet.AsQueryable();
if (documents)
query = query.Include(e => e.Documents);
if (receivers)
query = query.Include(e => e.Receivers);
if (history)
query = query.Include(e => e.History);
return await query.ToListAsync();
}
public async Task<Envelope?> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withReceivers = false, bool withHistory = false)
{
var query = _dbSet.Where(e => e.Uuid == uuid);
if (withDocuments)
query = query.Include(e => e.Documents);
if (withReceivers)
query = query.Include(e => e.Receivers);
if (withHistory)
query = query.Include(e => e.History);
return await query.FirstOrDefaultAsync();
}
} }
} }

View File

@@ -1,4 +1,5 @@
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Common; using EnvelopeGenerator.Common;
using EnvelopeGenerator.Web.Services; using EnvelopeGenerator.Web.Services;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@@ -9,17 +10,31 @@ namespace EnvelopeGenerator.Web.Controllers
{ {
private readonly EnvelopeOldService envelopeService; private readonly EnvelopeOldService envelopeService;
private readonly ActionService? actionService; private readonly ActionService? actionService;
private readonly IEnvelopeService _envelopeService;
public EnvelopeController(DatabaseService database, EnvelopeOldService envelope, ILogger<EnvelopeController> logger) : base(database, logger) public EnvelopeController(DatabaseService database, EnvelopeOldService envelope, ILogger<EnvelopeController> logger, IEnvelopeService envService) : base(database, logger)
{ {
envelopeService = envelope; envelopeService = envelope;
actionService = database?.Services?.actionService; actionService = database?.Services?.actionService;
_envelopeService = envService;
} }
[HttpGet] [HttpGet("api/envelope/{envelopeKey}")]
[Route("api/envelope/{envelopeKey}")]
public async Task<IActionResult> Get(string envelopeKey) public async Task<IActionResult> Get(string envelopeKey)
{ {
//_logger.LogInformation($"Loading Envelope by Key [{envelopeKey}]");
//Tuple<string, string> result = Helpers.DecodeEnvelopeReceiverId(envelopeKey);
//var envelopeUuid = result.Item1;
//var receiverSignature = result.Item2;
////var receiverId = receiverModel.GetReceiverIdBySignature(receiverSignature);
////_logger.LogInformation("Resolved receiver signature to receiverId [{0}]", receiverId);
//var envlopeServiceResult = await _envelopeService.ReadByUuidAsync(envelopeUuid, withDocuments:true, withReceivers:true, withHistory:true);
//_logger.LogInformation("Loading envelope..");
try try
{ {
// Validate Envelope Key and load envelope // Validate Envelope Key and load envelope
@@ -40,8 +55,7 @@ namespace EnvelopeGenerator.Web.Controllers
} }
} }
[HttpPost] [HttpPost("api/envelope/{envelopeKey}")]
[Route("api/envelope/{envelopeKey}")]
public async Task<IActionResult> Update(string envelopeKey, int index) public async Task<IActionResult> Update(string envelopeKey, int index)
{ {
try try

View File

@@ -1,4 +1,6 @@
using EnvelopeGenerator.Common; using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.Services;
using EnvelopeGenerator.Common;
using EnvelopeGenerator.Web.Models; using EnvelopeGenerator.Web.Models;
using EnvelopeGenerator.Web.Services; using EnvelopeGenerator.Web.Services;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@@ -9,24 +11,24 @@ namespace EnvelopeGenerator.Web.Controllers
{ {
public class HomeController : BaseController public class HomeController : BaseController
{ {
private readonly EnvelopeOldService _envelopeService; private readonly EnvelopeOldService envelopeOldService;
private readonly IConfiguration _config; private readonly IConfiguration _config;
private readonly IEnvelopeService _envelopeService;
public HomeController(DatabaseService databaseService, EnvelopeOldService envelopeService, ILogger<HomeController> logger, IConfiguration configuration) : base(databaseService, logger) public HomeController(DatabaseService databaseService, EnvelopeOldService envelopeOldService, ILogger<HomeController> logger, IConfiguration configuration, IEnvelopeService envelopeService) : base(databaseService, logger)
{ {
this.envelopeOldService = envelopeOldService;
_envelopeService = envelopeService; _envelopeService = envelopeService;
_config = configuration; _config = configuration;
} }
[HttpGet] [HttpGet("/")]
[Route("/")]
public IActionResult Index() public IActionResult Index()
{ {
return View(); return View();
} }
[HttpPost] [HttpPost("/")]
[Route("/")]
public IActionResult DebugEnvelopes([FromForm] string password) public IActionResult DebugEnvelopes([FromForm] string password)
{ {
try try
@@ -51,7 +53,7 @@ namespace EnvelopeGenerator.Web.Controllers
return View("Index"); return View("Index");
} }
List<Envelope> envelopes = _envelopeService.LoadEnvelopes(); List<Envelope> envelopes = envelopeOldService.LoadEnvelopes();
return View(envelopes); return View(envelopes);
} }
@@ -62,11 +64,10 @@ namespace EnvelopeGenerator.Web.Controllers
} }
} }
[HttpGet] [HttpGet("/EnvelopeKey/{envelopeReceiverId}")]
[Route("/EnvelopeKey/{envelopeReceiverId}")]
public async Task<IActionResult> ShowEnvelope([FromRoute] string envelopeReceiverId) public async Task<IActionResult> ShowEnvelope([FromRoute] string envelopeReceiverId)
{ {
EnvelopeResponse response = await _envelopeService.LoadEnvelope(envelopeReceiverId); EnvelopeResponse response = await envelopeOldService.LoadEnvelope(envelopeReceiverId);
if (response.Envelope.UseAccessCode) if (response.Envelope.UseAccessCode)
{ {
@@ -88,11 +89,10 @@ namespace EnvelopeGenerator.Web.Controllers
} }
} }
[HttpPost] [HttpPost("/EnvelopeKey/{envelopeReceiverId}/Locked")]
[Route("/EnvelopeKey/{envelopeReceiverId}/Locked")]
public async Task<IActionResult> ShowEnvelopePost([FromRoute] string envelopeReceiverId, [FromForm] string access_code) public async Task<IActionResult> ShowEnvelopePost([FromRoute] string envelopeReceiverId, [FromForm] string access_code)
{ {
EnvelopeResponse response = await _envelopeService.LoadEnvelope(envelopeReceiverId); EnvelopeResponse response = await envelopeOldService.LoadEnvelope(envelopeReceiverId);
string accessCode = response.Receiver.AccessCode; string accessCode = response.Receiver.AccessCode;
if (string.IsNullOrEmpty(access_code)) if (string.IsNullOrEmpty(access_code))
@@ -114,18 +114,21 @@ namespace EnvelopeGenerator.Web.Controllers
} }
} }
[HttpGet] [HttpGet("/EnvelopeKey/{envelopeReceiverId}/Locked")]
[Route("/EnvelopeKey/{envelopeReceiverId}/Locked")] public async Task<IActionResult> EnvelopeLocked([FromRoute] string envelopeReceiverId)
public IActionResult EnvelopeLocked([FromRoute] string envelopeReceiverId)
{ {
Tuple<string, string> decode = Common.Helpers.DecodeEnvelopeReceiverId(envelopeReceiverId);
var envelopeUuid = decode.Item1;
var envlopeServiceResult = await _envelopeService.ReadByUuidAsync(envelopeUuid, withDocuments: true, withReceivers: true, withHistory: true);
ViewData["Envelope"] = envlopeServiceResult.Data;
ViewData["EnvelopeKey"] = envelopeReceiverId; ViewData["EnvelopeKey"] = envelopeReceiverId;
return View(); return View();
} }
[HttpGet("/EnvelopeKey/{EnvelopeReceiverId}/Success")]
[HttpGet]
[Route("/EnvelopeKey/{EnvelopeReceiverId}/Success")]
public IActionResult EnvelopeSigned() public IActionResult EnvelopeSigned()
{ {
ViewData["EnvelopeKey"] = HttpContext.Request.RouteValues["EnvelopeReceiverId"]; ViewData["EnvelopeKey"] = HttpContext.Request.RouteValues["EnvelopeReceiverId"];
@@ -133,7 +136,6 @@ namespace EnvelopeGenerator.Web.Controllers
return View(); return View();
} }
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error() public IActionResult Error()
{ {

View File

@@ -3,6 +3,7 @@ using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs; using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities; using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts; using EnvelopeGenerator.Infrastructure.Contracts;
using Microsoft.AspNetCore.Mvc;
namespace EnvelopeGenerator.Web.Controllers namespace EnvelopeGenerator.Web.Controllers
{ {
@@ -10,7 +11,36 @@ namespace EnvelopeGenerator.Web.Controllers
{ {
public TestEnvelopeController(ILogger<TestEnvelopeController> logger, IEnvelopeService service) : base(logger, service) public TestEnvelopeController(ILogger<TestEnvelopeController> logger, IEnvelopeService service) : base(logger, service)
{ {
}
[NonAction]
public override Task<IActionResult> GetAll()
{
return base.GetAll();
}
[HttpGet]
public virtual async Task<IActionResult> GetAll([FromQuery] string? envelopeKey = default, [FromQuery] bool withDocuments = true, [FromQuery] bool withReceivers = true, [FromQuery] bool withHistory = true)
{
if(envelopeKey is not null)
{
Tuple<string, string> decode = Common.Helpers.DecodeEnvelopeReceiverId(envelopeKey);
var envelopeUuid = decode.Item1;
var envlopeServiceResult = await _service.ReadByUuidAsync(envelopeUuid, withDocuments: true, withReceivers: true, withHistory: true);
if (envlopeServiceResult.IsSuccess)
{
return Ok(envlopeServiceResult.Data);
}
return NotFound();
}
var result = await _service.ReadAllWithAsync(documents: withDocuments, receivers: withReceivers, history: withHistory);
if (result.IsSuccess)
{
return Ok(result);
}
return NotFound(result);
} }
} }
} }

View File

@@ -1,42 +1,25 @@
@{ @using EnvelopeGenerator.Application.DTOs;
@{
ViewData["Title"] = "Dokument unterschreiben"; ViewData["Title"] = "Dokument unterschreiben";
EnvelopeDto? envelopeDto = ViewData["envelope"] as EnvelopeDto;
} }
<nav class="navbar navbar-expand-lg bg-body-tertiary"> @if(envelopeDto is not null)
{
<nav class="navbar navbar-light bg-light">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria-expanded="false" aria-label="Toggle navigation">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="collapse navbar-collapse" id="navbarSupportedContent"> <div class="navbar-brand">Bitte prüfen Sie diese Dokumente und handeln Sie danach</div>
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>
<form class="d-flex" role="search">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</div> </div>
</nav> </nav>
<div class="collapse" id="navbarToggleExternalContent" data-bs-theme="light">
<div class="bg-light p-1">
<h5 class="text-body-emphasis h4">Collapsed content</h5>
<span class="text-body-secondary">Toggleable via the navbar brand.</span>
</div>
</div>
}
<script> <script>
document.addEventListener("DOMContentLoaded", async () => { document.addEventListener("DOMContentLoaded", async () => {
const app = new App("#app", "@ViewData["EnvelopeKey"]"); const app = new App("#app", "@ViewData["EnvelopeKey"]");

View File

@@ -14,8 +14,6 @@ class App {
this.container = container this.container = container
this.envelopeKey = envelopeKey this.envelopeKey = envelopeKey
// Initialize classes
console.debug('Initializing classes..')
this.UI = new UI() this.UI = new UI()
this.Network = new Network() this.Network = new Network()
this.Annotation = new Annotation() this.Annotation = new Annotation()
@@ -71,7 +69,6 @@ class App {
const arrayBuffer = documentResponse.data const arrayBuffer = documentResponse.data
// Load PSPDFKit // Load PSPDFKit
console.debug('Loading PSPDFKit..')
this.Instance = await this.UI.loadPSPDFKit(arrayBuffer, this.container) this.Instance = await this.UI.loadPSPDFKit(arrayBuffer, this.container)
this.UI.configurePSPDFKit(this.Instance, this.handleClick.bind(this)) this.UI.configurePSPDFKit(this.Instance, this.handleClick.bind(this))