Add EmailSender to dependency injection
parent
ac04fa1419
commit
41326e1edb
|
|
@ -12,7 +12,9 @@ using Microsoft.Extensions.Logging;
|
|||
using Microsoft.Extensions.Options;
|
||||
using OFBButte.Application.Configuration;
|
||||
using OFBButte.Application.Database;
|
||||
using OFBButte.Application.Email;
|
||||
using OFBButte.Database;
|
||||
using OFBButte.Infrastructure.Email;
|
||||
|
||||
namespace OFBButte.Api
|
||||
{
|
||||
|
|
@ -53,6 +55,13 @@ namespace OFBButte.Api
|
|||
OFBContext.UseMySql(o, Configuration.GetConnectionString("OFBContext"));
|
||||
});
|
||||
services.AddScoped<IOFBContext, OFBContext>(s => s.GetService<OFBContext>());
|
||||
|
||||
// Email Service
|
||||
services.AddScoped<IEmailSender, EmailSender>(s =>
|
||||
{
|
||||
var options = s.GetService<IOptions<AppSettings>>();
|
||||
return new EmailSender(options.Value.Environment != "Prod");
|
||||
});
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
|
|
|
|||
Loading…
Reference in New Issue