2024-04-11 12:41:44 +04:00
|
|
|
using AutoWorkshopBusinessLogic.BusinessLogics;
|
2024-04-19 22:47:28 +04:00
|
|
|
using AutoWorkshopBusinessLogic.MailWorker;
|
|
|
|
using AutoWorkshopContracts.BindingModels;
|
2024-04-11 12:41:44 +04:00
|
|
|
using AutoWorkshopContracts.BusinessLogicContracts;
|
2024-04-16 19:54:51 +04:00
|
|
|
using AutoWorkshopContracts.BusinessLogicsContracts;
|
2024-04-11 12:41:44 +04:00
|
|
|
using AutoWorkshopContracts.StoragesContracts;
|
|
|
|
using AutoWorkshopDatabaseImplement.Implements;
|
|
|
|
using Microsoft.OpenApi.Models;
|
|
|
|
|
2024-04-13 00:16:40 +04:00
|
|
|
var Builder = WebApplication.CreateBuilder(args);
|
|
|
|
Builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
|
|
|
Builder.Logging.AddLog4Net("log4net.config");
|
|
|
|
|
2024-04-11 12:41:44 +04:00
|
|
|
// Add services to the container.
|
2024-04-13 00:16:40 +04:00
|
|
|
Builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
|
|
|
Builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
|
|
|
Builder.Services.AddTransient<IRepairStorage, RepairStorage>();
|
2024-04-16 19:54:51 +04:00
|
|
|
Builder.Services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
2024-04-19 22:47:28 +04:00
|
|
|
Builder.Services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
2024-04-16 19:54:51 +04:00
|
|
|
|
2024-04-13 00:16:40 +04:00
|
|
|
Builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
|
|
|
Builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
|
|
|
Builder.Services.AddTransient<IRepairLogic, RepairLogic>();
|
2024-04-16 19:54:51 +04:00
|
|
|
Builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
2024-04-19 22:47:28 +04:00
|
|
|
Builder.Services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
|
|
|
|
2024-04-20 19:02:55 +04:00
|
|
|
Builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
2024-04-16 19:54:51 +04:00
|
|
|
|
2024-04-13 00:16:40 +04:00
|
|
|
Builder.Services.AddControllers();
|
2024-04-11 12:41:44 +04:00
|
|
|
|
2024-04-13 00:16:40 +04:00
|
|
|
Builder.Services.AddEndpointsApiExplorer();
|
|
|
|
Builder.Services.AddSwaggerGen(c =>
|
2024-04-11 12:41:44 +04:00
|
|
|
{
|
|
|
|
c.SwaggerDoc("v1", new OpenApiInfo
|
|
|
|
{
|
|
|
|
Title = "AutoWorkshopRestApi",
|
|
|
|
Version = "v1"
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2024-04-13 00:16:40 +04:00
|
|
|
var App = Builder.Build();
|
|
|
|
|
2024-04-19 22:47:28 +04:00
|
|
|
var MailSender = App.Services.GetService<AbstractMailWorker>();
|
|
|
|
MailSender?.MailConfig(new MailConfigBindingModel
|
|
|
|
{
|
|
|
|
MailLogin = Builder.Configuration?.GetSection("MailLogin")?.Value?.ToString() ?? string.Empty,
|
|
|
|
MailPassword = Builder.Configuration?.GetSection("MailPassword")?.Value?.ToString() ?? string.Empty,
|
|
|
|
SmtpClientHost = Builder.Configuration?.GetSection("SmtpClientHost")?.Value?.ToString() ?? string.Empty,
|
|
|
|
SmtpClientPort = Convert.ToInt32(Builder.Configuration?.GetSection("SmtpClientPort")?.Value?.ToString()),
|
|
|
|
PopHost = Builder.Configuration?.GetSection("PopHost")?.Value?.ToString() ?? string.Empty,
|
|
|
|
PopPort = Convert.ToInt32(Builder.Configuration?.GetSection("PopPort")?.Value?.ToString())
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2024-04-13 00:16:40 +04:00
|
|
|
if (App.Environment.IsDevelopment())
|
2024-04-11 12:41:44 +04:00
|
|
|
{
|
2024-04-13 00:16:40 +04:00
|
|
|
App.UseSwagger();
|
|
|
|
App.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json",
|
2024-04-11 12:41:44 +04:00
|
|
|
"AutoWorkshopRestApi v1"));
|
|
|
|
}
|
2024-04-13 00:16:40 +04:00
|
|
|
|
|
|
|
App.UseHttpsRedirection();
|
|
|
|
App.UseAuthorization();
|
|
|
|
App.MapControllers();
|
|
|
|
|
|
|
|
App.Run();
|