using ComputerStoreBusinessLogic.BusinessLogic; using ComputerStoreBusinessLogic.MailStuff; using ComputerStoreBusinessLogic.OfficePackage; using ComputerStoreBusinessLogic.OfficePackage.Implements; using ComputerStoreContracts.BindingModels; using ComputerStoreContracts.BusinessLogicContracts; using ComputerStoreContracts.StorageContracts; using ComputerStoreDatabaseImplement.Implements; var builder = WebApplication.CreateBuilder(args); builder.Logging.SetMinimumLevel(LogLevel.Trace); builder.Logging.AddLog4Net("log4net.config"); // Add services to the container. builder.Services.AddTransient<IEmployeeStorage,EmployeeStorage>(); builder.Services.AddTransient<IComponentStorage, ComponentStorage>(); builder.Services.AddTransient<IPCStorage,PCStorage>(); builder.Services.AddTransient<IProductStorage, ProductStorage>(); builder.Services.AddTransient<IConsignmentStorage, ConsignmentStorage>(); builder.Services.AddTransient<IRequestComponentStorage, RequestComponentStorage>(); builder.Services.AddTransient<IRequestStorage, RequestStorage>(); builder.Services.AddTransient<IOrderStorage, OrderStorage>(); builder.Services.AddTransient<ISellerStorage, SellerStorage>(); builder.Services.AddTransient<IOrderLogic, OrderLogic>(); builder.Services.AddTransient<IReportOrderLogic, ReportOrderLogic>(); builder.Services.AddTransient<ISellerLogic, SellerLogic>(); builder.Services.AddTransient<IEmployeeLogic,EmployeeLogic>(); builder.Services.AddTransient<IComponentLogic, ComponentLogic>(); builder.Services.AddTransient<IEmployeeReportLogic, EmployeeReportLogic>(); builder.Services.AddTransient<IPCLogic, PCLogic>(); builder.Services.AddTransient<IProductLogic, ProductLogic>(); builder.Services.AddTransient<IConsignmentLogic,ConsignmentLogic>(); builder.Services.AddTransient<IRequestComponentLogic, RequestComponentLogic>(); builder.Services.AddTransient<IRequestLogic, RequestLogic>(); builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>(); builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>(); builder.Services.AddTransient<AbstractSaveToPDF, SaveToPDF>(); builder.Services.AddSingleton<AbstractMail, MailKit>(); builder.Services.AddControllers().AddNewtonsoftJson(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); var app = builder.Build(); var mailSender = app.Services.GetService<AbstractMail>(); mailSender?.MailConfig(new MailConfigBindingModel { Login = builder.Configuration?.GetSection("MailLogin")?.Value?.ToString() ?? string.Empty, Password = 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()) }); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); app.Run();