refactor(EnvelopeSmsService): Initialisiert mit Schnittstelle, DI-Injektion und Konfigurationen.
This commit is contained in:
parent
22347a0202
commit
1941de1928
@ -1,6 +1,6 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace EnvelopeGenerator.Web.Models
|
||||
namespace EnvelopeGenerator.Application.Configurations
|
||||
{
|
||||
public class TotpSmsParams
|
||||
{
|
||||
@ -0,0 +1,5 @@
|
||||
namespace EnvelopeGenerator.Application.Contracts;
|
||||
|
||||
public interface IEnvelopeSmsService
|
||||
{
|
||||
}
|
||||
@ -16,7 +16,7 @@ namespace EnvelopeGenerator.Application.Extensions
|
||||
{
|
||||
public static class DIExtensions
|
||||
{
|
||||
public static IServiceCollection AddEnvelopeGenerator(this IServiceCollection services, IConfigurationSection dispatcherConfigSection, IConfigurationSection mailConfigSection, IConfigurationSection smsConfigSection, IConfigurationSection codeGeneratorConfigSection, IConfigurationSection envelopeReceiverCacheParamsSection)
|
||||
public static IServiceCollection AddEnvelopeGenerator(this IServiceCollection services, IConfigurationSection dispatcherConfigSection, IConfigurationSection mailConfigSection, IConfigurationSection smsConfigSection, IConfigurationSection codeGeneratorConfigSection, IConfigurationSection envelopeReceiverCacheParamsSection, IConfigurationSection totpSmsParamsSection)
|
||||
{
|
||||
//Inject CRUD Service and repositoriesad
|
||||
services.TryAddScoped<IConfigRepository, ConfigRepository>();
|
||||
@ -58,9 +58,11 @@ namespace EnvelopeGenerator.Application.Extensions
|
||||
services.Configure<MailConfig>(mailConfigSection);
|
||||
services.Configure<CodeGeneratorParams>(codeGeneratorConfigSection);
|
||||
services.Configure<EnvelopeReceiverCacheParams>(envelopeReceiverCacheParamsSection);
|
||||
services.Configure<TotpSmsParams>(totpSmsParamsSection);
|
||||
|
||||
services.AddHttpClientService<SmsParams>(smsConfigSection);
|
||||
services.TryAddSingleton<ISmsSender, GTXSmsSender>();
|
||||
services.TryAddSingleton<IEnvelopeSmsService, EnvelopeSmsService>();
|
||||
services.TryAddSingleton<ICodeGenerator, CodeGenerator>();
|
||||
services.TryAddSingleton<QRCodeGenerator>();
|
||||
|
||||
@ -72,6 +74,7 @@ namespace EnvelopeGenerator.Application.Extensions
|
||||
mailConfigSection: config.GetSection("MailConfig"),
|
||||
smsConfigSection: config.GetSection("SmsConfig"),
|
||||
codeGeneratorConfigSection: config.GetSection("CodeGeneratorParams"),
|
||||
envelopeReceiverCacheParamsSection: config.GetSection("EnvelopeReceiverCacheParams"));
|
||||
envelopeReceiverCacheParamsSection: config.GetSection("EnvelopeReceiverCacheParams"),
|
||||
totpSmsParamsSection: config.GetSection("TotpSmsParams"));
|
||||
}
|
||||
}
|
||||
18
EnvelopeGenerator.Application/Services/EnvelopeSmsService.cs
Normal file
18
EnvelopeGenerator.Application/Services/EnvelopeSmsService.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using EnvelopeGenerator.Application.Configurations;
|
||||
using EnvelopeGenerator.Application.Contracts;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace EnvelopeGenerator.Application.Services;
|
||||
|
||||
public class EnvelopeSmsService : IEnvelopeSmsService
|
||||
{
|
||||
private readonly ISmsSender _sender;
|
||||
|
||||
private readonly TotpSmsParams _totpSmsParams;
|
||||
|
||||
public EnvelopeSmsService(ISmsSender sender, IOptions<TotpSmsParams> totpSmsParamsOptions)
|
||||
{
|
||||
_sender = sender;
|
||||
_totpSmsParams = totpSmsParamsOptions.Value;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user