Deprecate repositories and update service interfaces

- Marked `IEnvelopeReceiverRepository` and several repository classes as obsolete, recommending the use of `IRepository`.
- Corrected `using` directive in `IReceiverService.cs`.
- Removed `UpdateAsync` method from `IReceiverService`.
- Enhanced `ISmsSender` interface with new properties and methods.
- Updated `ReceiverCreateDto`, `ReceiverReadDto`, and `UserReceiverDto` to enforce non-nullable properties.
- Refactored `TestReceiverController` to suggest using `MediatR`.
This commit is contained in:
2025-06-30 13:37:54 +02:00
parent e3cb2ec219
commit 94d43bce24
17 changed files with 67 additions and 23 deletions

View File

@@ -6,6 +6,7 @@ namespace EnvelopeGenerator.Application.Contracts.Repositories;
/// <summary>
///
/// </summary>
[Obsolete("Use IRepository")]
public interface IEnvelopeReceiverRepository : ICRUDRepository<EnvelopeReceiver, (int Envelope, int Receiver)>
{
/// <summary>

View File

@@ -1,5 +1,4 @@
using DigitalData.Core.Abstractions;
using DigitalData.Core.Abstraction.Application;
using DigitalData.Core.Abstraction.Application;
using DigitalData.Core.Abstraction.Application.DTO;
using EnvelopeGenerator.Application.DTOs.Receiver;
using EnvelopeGenerator.Domain.Entities;
@@ -27,12 +26,4 @@ public interface IReceiverService : ICRUDService<ReceiverCreateDto, ReceiverRead
/// <param name="signature"></param>
/// <returns></returns>
Task<Result> DeleteByAsync(string? emailAddress = null, string? signature = null);
/// <summary>
///
/// </summary>
/// <typeparam name="TUpdateDto"></typeparam>
/// <param name="updateDto"></param>
/// <returns></returns>
Task<Result> UpdateAsync<TUpdateDto>(TUpdateDto updateDto);
}

View File

@@ -3,9 +3,21 @@
namespace EnvelopeGenerator.Application.Contracts.Services;
//TODO: move to DigitalData.Core
/// <summary>
///
/// </summary>
public interface ISmsSender
{
/// <summary>
///
/// </summary>
string ServiceProvider { get; }
/// <summary>
///
/// </summary>
/// <param name="recipient"></param>
/// <param name="message"></param>
/// <returns></returns>
Task<SmsResponse> SendSmsAsync(string recipient, string message);
}

View File

@@ -18,7 +18,7 @@ public record ReceiverCreateDto
{
_sha256HexOfMail = new(() =>
{
var bytes_arr = Encoding.UTF8.GetBytes(EmailAddress.ToUpper());
var bytes_arr = Encoding.UTF8.GetBytes(EmailAddress!.ToUpper());
var hash_arr = SHA256.HashData(bytes_arr);
var hexa_str = BitConverter.ToString(hash_arr);
return hexa_str.Replace("-", string.Empty);
@@ -37,7 +37,7 @@ public record ReceiverCreateDto
public string? TotpSecretkey { get; init; }
/// <summary>
/// var bytes_arr = Encoding.UTF8.GetBytes(EmailAddress.ToUpper());<br>
/// var bytes_arr = Encoding.UTF8.GetBytes(EmailAddress.ToUpper());<br/>
/// var hash_arr = SHA256.HashData(bytes_arr);
/// var hexa_str = BitConverter.ToString(hash_arr);
/// return hexa_str.Replace("-", string.Empty);

View File

@@ -4,26 +4,57 @@ using System.Text.Json.Serialization;
namespace EnvelopeGenerator.Application.DTOs.Receiver;
/// <summary>
///
/// </summary>
[ApiExplorerSettings(IgnoreApi = true)]
public class ReceiverReadDto
{
/// <summary>
///
/// </summary>
public int Id { get; set; }
public string EmailAddress { get; set; }
/// <summary>
///
/// </summary>
public required string EmailAddress { get; set; }
public string Signature { get; set; }
/// <summary>
///
/// </summary>
public required string Signature { get; set; }
/// <summary>
///
/// </summary>
public DateTime AddedWhen { get; set; }
/// <summary>
///
/// </summary>
[JsonIgnore]
public IEnumerable<EnvelopeReceiverBasicDto>? EnvelopeReceivers { get; set; }
/// <summary>
///
/// </summary>
public string? LastUsedName => EnvelopeReceivers?.LastOrDefault()?.Name;
/// <summary>
///
/// </summary>
public string? TotpSecretkey { get; set; } = null;
/// <summary>
///
/// </summary>
public DateTime? TfaRegDeadline { get; set; }
/// <summary>
///
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return Id.GetHashCode();

View File

@@ -26,7 +26,7 @@ public class UserReceiverDto
/// <summary>
/// Gets or sets the name of the receiver.
/// </summary>
public string Name { get; set; }
public required string Name { get; set; }
/// <summary>
/// Gets or sets the company name of the receiver.