feat(EnvelopeReceiverReadOnly): Controller initialisieren
- Join mit Receiver und Read - DI-Konfiguration hinzufügen - Auslöser hinzufügen (TBSIG_ENVELOPE_RECEIVER_READ_ONLY_UPD)
This commit is contained in:
parent
0e91df7acc
commit
e17f7df930
@ -5,11 +5,6 @@ using EnvelopeGenerator.Application.Services;
|
|||||||
using EnvelopeGenerator.Infrastructure.Contracts;
|
using EnvelopeGenerator.Infrastructure.Contracts;
|
||||||
using EnvelopeGenerator.Infrastructure.Repositories;
|
using EnvelopeGenerator.Infrastructure.Repositories;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Application
|
namespace EnvelopeGenerator.Application
|
||||||
{
|
{
|
||||||
@ -33,6 +28,7 @@ namespace EnvelopeGenerator.Application
|
|||||||
services.AddScoped<IEnvelopeTypeRepository, EnvelopeTypeRepository>();
|
services.AddScoped<IEnvelopeTypeRepository, EnvelopeTypeRepository>();
|
||||||
services.AddScoped<IReceiverRepository, ReceiverRepository>();
|
services.AddScoped<IReceiverRepository, ReceiverRepository>();
|
||||||
services.AddScoped<IUserReceiverRepository, UserReceiverRepository>();
|
services.AddScoped<IUserReceiverRepository, UserReceiverRepository>();
|
||||||
|
services.AddScoped<IEnvelopeReceiverReadOnlyRepository, EnvelopeReceiverReadOnlyRepository>();
|
||||||
services.AddScoped<IConfigService, ConfigService>();
|
services.AddScoped<IConfigService, ConfigService>();
|
||||||
services.AddScoped<IDocumentReceiverElementService, DocumentReceiverElementService>();
|
services.AddScoped<IDocumentReceiverElementService, DocumentReceiverElementService>();
|
||||||
services.AddScoped<IEnvelopeDocumentService, EnvelopeDocumentService>();
|
services.AddScoped<IEnvelopeDocumentService, EnvelopeDocumentService>();
|
||||||
@ -46,6 +42,7 @@ namespace EnvelopeGenerator.Application
|
|||||||
services.AddScoped<IEnvelopeTypeService, EnvelopeTypeService>();
|
services.AddScoped<IEnvelopeTypeService, EnvelopeTypeService>();
|
||||||
services.AddScoped<IReceiverService, ReceiverService>();
|
services.AddScoped<IReceiverService, ReceiverService>();
|
||||||
services.AddScoped<IUserReceiverService, UserReceiverService>();
|
services.AddScoped<IUserReceiverService, UserReceiverService>();
|
||||||
|
services.AddScoped<IEnvelopeReceiverReadOnlyService, EnvelopeReceiverReadOnlyService>();
|
||||||
|
|
||||||
//Auto mapping profiles
|
//Auto mapping profiles
|
||||||
services.AddAutoMapper(typeof(BasicDtoMappingProfile).Assembly);
|
services.AddAutoMapper(typeof(BasicDtoMappingProfile).Assembly);
|
||||||
|
|||||||
@ -1,11 +1,15 @@
|
|||||||
namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly
|
||||||
{
|
{
|
||||||
public record EnvelopeReceiverReadOnlyCreateDto(
|
public record EnvelopeReceiverReadOnlyCreateDto(
|
||||||
long EnvelopeId,
|
long EnvelopeId,
|
||||||
string ReceiverMail,
|
string ReceiverMail,
|
||||||
DateTime DateValid,
|
DateTime DateValid)
|
||||||
string AddedWho)
|
|
||||||
{
|
{
|
||||||
|
[JsonIgnore]
|
||||||
|
public string? AddedWho { get; set; }
|
||||||
|
|
||||||
public DateTime AddedWhen { get; } = DateTime.Now;
|
public DateTime AddedWhen { get; } = DateTime.Now;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -1,4 +1,6 @@
|
|||||||
namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly
|
using EnvelopeGenerator.Application.DTOs.Receiver;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly
|
||||||
{
|
{
|
||||||
public record EnvelopeReceiverReadOnlyDto(
|
public record EnvelopeReceiverReadOnlyDto(
|
||||||
long Id,
|
long Id,
|
||||||
@ -9,5 +11,6 @@
|
|||||||
string AddedWho,
|
string AddedWho,
|
||||||
EnvelopeDto? Envelope = null,
|
EnvelopeDto? Envelope = null,
|
||||||
string? ChangedWho = null,
|
string? ChangedWho = null,
|
||||||
DateTime? ChangedWhen = null);
|
DateTime? ChangedWhen = null,
|
||||||
|
ReceiverReadDto? Receiver = null);
|
||||||
}
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using DigitalData.Core.Abstractions;
|
using DigitalData.Core.Abstractions;
|
||||||
|
using DigitalData.EmailProfilerDispatcher.Abstraction.Attributes;
|
||||||
|
|
||||||
namespace EnvelopeGenerator.Domain.Entities
|
namespace EnvelopeGenerator.Domain.Entities
|
||||||
{
|
{
|
||||||
@ -16,9 +17,13 @@ namespace EnvelopeGenerator.Domain.Entities
|
|||||||
[Required]
|
[Required]
|
||||||
public long EnvelopeId { get; init; }
|
public long EnvelopeId { get; init; }
|
||||||
|
|
||||||
|
[ForeignKey("EnvelopeId")]
|
||||||
|
public Envelope? Envelope { get; init; }
|
||||||
|
|
||||||
[Column("RECEIVER_MAIL")]
|
[Column("RECEIVER_MAIL")]
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength(250)]
|
[StringLength(250)]
|
||||||
|
[TemplatePlaceholder("NAME_RECEIVER")]
|
||||||
public required string ReceiverMail { get; init; }
|
public required string ReceiverMail { get; init; }
|
||||||
|
|
||||||
[Column("DATE_VALID")]
|
[Column("DATE_VALID")]
|
||||||
@ -30,6 +35,8 @@ namespace EnvelopeGenerator.Domain.Entities
|
|||||||
[StringLength(100)]
|
[StringLength(100)]
|
||||||
public required string AddedWho { get; init; }
|
public required string AddedWho { get; init; }
|
||||||
|
|
||||||
|
public Receiver? Receiver { get; init; }
|
||||||
|
|
||||||
[Column("ADDED_WHEN")]
|
[Column("ADDED_WHEN")]
|
||||||
[Required]
|
[Required]
|
||||||
public DateTime AddedWhen { get; init; }
|
public DateTime AddedWhen { get; init; }
|
||||||
|
|||||||
@ -129,12 +129,24 @@ namespace EnvelopeGenerator.Infrastructure
|
|||||||
.HasForeignKey(eh => eh.UserReference)
|
.HasForeignKey(eh => eh.UserReference)
|
||||||
.HasPrincipalKey(e => e.Email);
|
.HasPrincipalKey(e => e.Email);
|
||||||
|
|
||||||
|
modelBuilder.Entity<EnvelopeReceiverReadOnly>()
|
||||||
|
.HasOne(erro => erro.Receiver)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(erro => erro.AddedWho)
|
||||||
|
.HasPrincipalKey(r => r.EmailAddress);
|
||||||
|
|
||||||
|
modelBuilder.Entity<EnvelopeReceiverReadOnly>()
|
||||||
|
.HasOne(erro => erro.Envelope)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(erro => (int) erro.EnvelopeId);
|
||||||
|
|
||||||
// Configure entities to handle database triggers
|
// Configure entities to handle database triggers
|
||||||
modelBuilder.Entity<Envelope>().ToTable(tb => tb.HasTrigger("TBSIG_ENVELOPE_HISTORY_AFT_INS"));
|
modelBuilder.Entity<Envelope>().ToTable(tb => tb.HasTrigger("TBSIG_ENVELOPE_HISTORY_AFT_INS"));
|
||||||
modelBuilder.Entity<EnvelopeHistory>().ToTable(tb => tb.HasTrigger("TBSIG_ENVELOPE_HISTORY_AFT_INS"));
|
modelBuilder.Entity<EnvelopeHistory>().ToTable(tb => tb.HasTrigger("TBSIG_ENVELOPE_HISTORY_AFT_INS"));
|
||||||
modelBuilder.Entity<EmailOut>().ToTable(tb => tb.HasTrigger("TBEMLP_EMAIL_OUT_AFT_INS"));
|
modelBuilder.Entity<EmailOut>().ToTable(tb => tb.HasTrigger("TBEMLP_EMAIL_OUT_AFT_INS"));
|
||||||
modelBuilder.Entity<EmailOut>().ToTable(tb => tb.HasTrigger("TBEMLP_EMAIL_OUT_AFT_UPD"));
|
modelBuilder.Entity<EmailOut>().ToTable(tb => tb.HasTrigger("TBEMLP_EMAIL_OUT_AFT_UPD"));
|
||||||
|
modelBuilder.Entity<EnvelopeReceiverReadOnly>().ToTable(tb => tb.HasTrigger("TBSIG_ENVELOPE_RECEIVER_READ_ONLY_UPD"));
|
||||||
|
|
||||||
//configure model builder for user manager tables
|
//configure model builder for user manager tables
|
||||||
modelBuilder.ConfigureUserManager();
|
modelBuilder.ConfigureUserManager();
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
using DigitalData.Core.Infrastructure;
|
using DigitalData.Core.Infrastructure;
|
||||||
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
|
||||||
{
|
{
|
||||||
@ -9,5 +10,12 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
|
|||||||
public EnvelopeReceiverReadOnlyRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeReceiverReadOnlys)
|
public EnvelopeReceiverReadOnlyRepository(EGDbContext dbContext) : base(dbContext, dbContext.EnvelopeReceiverReadOnlys)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IQueryable<EnvelopeReceiverReadOnly> ReadOnly()
|
||||||
|
{
|
||||||
|
return base.ReadOnly()
|
||||||
|
.Include(erro => erro.Envelope)
|
||||||
|
.Include(erro => erro.Receiver);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
54
EnvelopeGenerator.Web/Controllers/ReadOnlyController.cs
Normal file
54
EnvelopeGenerator.Web/Controllers/ReadOnlyController.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
using DigitalData.Core.DTO;
|
||||||
|
using EnvelopeGenerator.Application.Contracts;
|
||||||
|
using EnvelopeGenerator.Application.DTOs.EnvelopeReceiverReadOnly;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace EnvelopeGenerator.Web.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class ReadOnlyController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ILogger<ReadOnlyController> _logger;
|
||||||
|
|
||||||
|
private readonly IEnvelopeReceiverReadOnlyService _erroService;
|
||||||
|
|
||||||
|
public ReadOnlyController(ILogger<ReadOnlyController> logger, IEnvelopeReceiverReadOnlyService erroService)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_erroService = erroService;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Authorize]
|
||||||
|
public async Task<IActionResult> GetAllAsync()
|
||||||
|
{
|
||||||
|
var res = await _erroService.ReadAllAsync();
|
||||||
|
return Ok(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Authorize]
|
||||||
|
public async Task<IActionResult> CreateAsync([FromBody] EnvelopeReceiverReadOnlyCreateDto createDto)
|
||||||
|
{
|
||||||
|
//set AddedWho
|
||||||
|
var authReceiverMail = this.GetAuthReceiverMail();
|
||||||
|
if (authReceiverMail is null)
|
||||||
|
{
|
||||||
|
_logger.LogError("Email clam is not found in envelope-receiver-read-only creation process. Create DTO is:\n {dto}", JsonConvert.SerializeObject(createDto));
|
||||||
|
|
||||||
|
return Unauthorized();
|
||||||
|
}
|
||||||
|
createDto.AddedWho = authReceiverMail;
|
||||||
|
|
||||||
|
return await _erroService.CreateAsync(createDto: createDto).ThenAsync(
|
||||||
|
Success: id => Ok(id),
|
||||||
|
Fail: IActionResult (msg, ntc) =>
|
||||||
|
{
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -16,7 +16,7 @@
|
|||||||
},
|
},
|
||||||
"AdminPassword": "dd",
|
"AdminPassword": "dd",
|
||||||
"PSPDFKitLicenseKey": "SXCtGGY9XA-31OGUXQK-r7c6AkdLGPm2ljuyDr1qu0kkhLvydg-Do-fxpNUF4Rq3fS_xAnZRNFRHbXpE6sQ2BMcCSVTcXVJO6tPviexjpiT-HnrDEySlUERJnnvh-tmeOWprxS6BySPnSILkmaVQtUfOIUS-cUbvvEYHTvQBKbSF8di4XHQFyfv49ihr51axm3NVV3AXwh2EiKL5C5XdqBZ4sQ4O7vXBjM2zvxdPxlxdcNYmiU83uAzw7B83O_jubPzya4CdUHh_YH7Nlp2gP56MeG1Sw2JhMtfG3Rj14Sg4ctaeL9p6AEWca5dDjJ2li5tFIV2fQSsw6A_cowLu0gtMm5i8IfJXeIcQbMC2-0wGv1oe9hZYJvFMdzhTM_FiejM0agemxt3lJyzuyP8zbBSOgp7Si6A85krLWPZptyZBTG7pp7IHboUHfPMxCXqi-zMsqewOJtQBE2mjntU-lPryKnssOpMPfswwQX7QSkJYV5EMqNmEhQX6mEkp2wcqFzMC7bJQew1aO4pOpvChUaMvb1vgRek0HxLag0nwQYX2YrYGh7F_xXJs-8HNwJe8H0-eW4x4faayCgM5rB5772CCCsD9ThZcvXFrjNHHLGJ8WuBUFm6LArvSfFQdii_7j-_sqHMpeKZt26NFgivj1A==",
|
"PSPDFKitLicenseKey": "SXCtGGY9XA-31OGUXQK-r7c6AkdLGPm2ljuyDr1qu0kkhLvydg-Do-fxpNUF4Rq3fS_xAnZRNFRHbXpE6sQ2BMcCSVTcXVJO6tPviexjpiT-HnrDEySlUERJnnvh-tmeOWprxS6BySPnSILkmaVQtUfOIUS-cUbvvEYHTvQBKbSF8di4XHQFyfv49ihr51axm3NVV3AXwh2EiKL5C5XdqBZ4sQ4O7vXBjM2zvxdPxlxdcNYmiU83uAzw7B83O_jubPzya4CdUHh_YH7Nlp2gP56MeG1Sw2JhMtfG3Rj14Sg4ctaeL9p6AEWca5dDjJ2li5tFIV2fQSsw6A_cowLu0gtMm5i8IfJXeIcQbMC2-0wGv1oe9hZYJvFMdzhTM_FiejM0agemxt3lJyzuyP8zbBSOgp7Si6A85krLWPZptyZBTG7pp7IHboUHfPMxCXqi-zMsqewOJtQBE2mjntU-lPryKnssOpMPfswwQX7QSkJYV5EMqNmEhQX6mEkp2wcqFzMC7bJQew1aO4pOpvChUaMvb1vgRek0HxLag0nwQYX2YrYGh7F_xXJs-8HNwJe8H0-eW4x4faayCgM5rB5772CCCsD9ThZcvXFrjNHHLGJ8WuBUFm6LArvSfFQdii_7j-_sqHMpeKZt26NFgivj1A==",
|
||||||
"UseCSPInDev": true,
|
"UseCSPInDev": false,
|
||||||
"Content-Security-Policy": [ // The first format parameter {0} will be replaced by the nonce value.
|
"Content-Security-Policy": [ // The first format parameter {0} will be replaced by the nonce value.
|
||||||
"default-src 'self'",
|
"default-src 'self'",
|
||||||
"script-src 'self' 'nonce-{0}' 'unsafe-eval'",
|
"script-src 'self' 'nonce-{0}' 'unsafe-eval'",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user