SushiBarBase/SushiBar/SushiBarRestApi/Program.cs
2024-05-22 10:46:39 +04:00

52 lines
1.6 KiB
C#

using SushiBarBusinessLogic.BusinessLogics;
using SushiBarBusinessLogic.MailWorker;
using SushiBarContracts.BindingModels;
using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.StoragesContracts;
using SushiBarDatabaseImplement.Implements;
using static Org.BouncyCastle.Math.EC.ECCurve;
var builder = WebApplication.CreateBuilder(args);
builder.Logging.SetMinimumLevel(LogLevel.Information);
builder.Logging.AddLog4Net("log4net.config");
// Add services to the container.
builder.Services
.AddSingleton<IClientStorage, ClientStorage>()
.AddSingleton<IOrderStorage, OrderStorage>()
.AddSingleton<ISushiStorage, SushiStorage>()
.AddSingleton<IMessageInfoStorage, MessageInfoStorage>();
builder.Services
.AddSingleton<IOrderLogic, OrderLogic>()
.AddSingleton<IClientLogic, ClientLogic>()
.AddSingleton<ISushiLogic, SushiLogic>()
.AddSingleton<IMessageInfoLogic, MessageInfoLogic>();
builder.Services
.AddSingleton<AbstractMailWorker, MailKitWorker>();
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
MailConfigBindingModel? mailSender = builder.Configuration.GetSection("MailConfigBindingModel").Get<MailConfigBindingModel>();
app.Services.GetService<AbstractMailWorker>()?.MailConfig(mailSender!);
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseAuthorization();
app.MapControllers();
app.Run();