2023-04-07 19:18:33 +04:00
|
|
|
using ComputerShopBusinessLogic.BusinessLogics;
|
2023-05-24 21:41:02 +04:00
|
|
|
using ComputerShopBusinessLogic.MailWorker;
|
2023-05-19 19:34:21 +04:00
|
|
|
using ComputerShopBusinessLogic.OfficePackage;
|
|
|
|
using ComputerShopBusinessLogic.OfficePackage.Implements;
|
2023-05-24 21:41:02 +04:00
|
|
|
using ComputerShopContracts.BindingModels;
|
2023-04-07 17:53:57 +04:00
|
|
|
using ComputerShopContracts.BusinessLogicContracts;
|
|
|
|
using ComputerShopContracts.StorageContracts;
|
|
|
|
using ComputerShopDatabaseImplement.Implements;
|
|
|
|
using Microsoft.OpenApi.Models;
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
|
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
|
|
|
builder.Logging.AddLog4Net("log4net.config");
|
|
|
|
|
|
|
|
// Add services to the container.
|
|
|
|
|
|
|
|
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
|
|
|
builder.Services.AddTransient<IPurchaseStorage, PurchaseStorage>();
|
|
|
|
builder.Services.AddTransient<IComponentStorage, ComponentStorage>();
|
2023-04-09 11:30:54 +04:00
|
|
|
builder.Services.AddTransient<IAssemblyStorage, AssemblyStorage>();
|
2023-05-19 19:34:21 +04:00
|
|
|
builder.Services.AddTransient<IEquipmentReceivingStorage, EquipmentReceivingStorage>();
|
|
|
|
builder.Services.AddTransient<ISupplyStorage, SupplyStorage>();
|
2023-12-01 19:59:06 +04:00
|
|
|
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
2023-04-09 11:30:54 +04:00
|
|
|
|
2023-04-07 19:18:33 +04:00
|
|
|
builder.Services.AddTransient<IPurchaseLogic, PurchaseLogic>();
|
|
|
|
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
|
|
|
builder.Services.AddTransient<IComponentLogic, ComponentLogic>();
|
2023-04-09 11:30:54 +04:00
|
|
|
builder.Services.AddTransient<IAssemblyLogic, AssemblyLogic>();
|
2023-05-19 19:34:21 +04:00
|
|
|
builder.Services.AddTransient<IEquipmentReceivingLogic, EquipmentReceivingLogic>();
|
2023-05-19 19:22:24 +04:00
|
|
|
builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
2023-12-02 01:30:33 +04:00
|
|
|
builder.Services.AddTransient<ISupplyLogic, SupplyLogic>();
|
2023-12-01 19:59:06 +04:00
|
|
|
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
|
|
|
|
2023-04-07 17:53:57 +04:00
|
|
|
|
2023-12-02 01:30:33 +04:00
|
|
|
|
2023-05-19 19:34:21 +04:00
|
|
|
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
|
|
|
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
|
|
|
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
|
|
|
|
2023-05-24 21:41:02 +04:00
|
|
|
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
|
|
|
|
2023-04-07 17:53:57 +04:00
|
|
|
builder.Services.AddControllers();
|
|
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
|
|
builder.Services.AddSwaggerGen(c =>
|
|
|
|
{
|
|
|
|
c.SwaggerDoc("v1", new OpenApiInfo
|
|
|
|
{
|
|
|
|
Title = "ComputerShopRestApi",
|
|
|
|
Version
|
|
|
|
= "v1"
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
2023-05-24 21:41:02 +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())
|
|
|
|
});
|
|
|
|
|
2023-04-07 17:53:57 +04:00
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
|
|
{
|
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json",
|
|
|
|
"ComputerShopRestApi v1"));
|
|
|
|
}
|
|
|
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
app.MapControllers();
|
|
|
|
|
|
|
|
app.Run();
|