67 lines
2.9 KiB
C#
67 lines
2.9 KiB
C#
using ComputerHardwareStoreBusinessLogic.BusinessLogic;
|
|
using ComputerHardwareStoreBusinessLogic.MailWorker;
|
|
using ComputerHardwareStoreContracts.BindingModels;
|
|
using ComputerHardwareStoreContracts.BusinessLogicsContracts;
|
|
using ComputerHardwareStoreContracts.StorageContracts;
|
|
using ComputerHardwareStoreDatabaseImplement.Implements;
|
|
using Microsoft.OpenApi.Models;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddControllers();
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
// получаем строку подключения из файла конфигурации
|
|
//DBSetting.ConectionString = builder.Configuration.GetConnectionString("DefaultConnection");
|
|
|
|
builder.Services.AddSingleton<IComponentStorage, ComponentStorage >();
|
|
builder.Services.AddSingleton<IStoreKeeperStorage, StoreKeeperStorage>();
|
|
builder.Services.AddSingleton<IProductStorage, ProductStorage>();
|
|
builder.Services.AddSingleton<IOrderStorage, OrderStorage>();
|
|
builder.Services.AddSingleton<IBuildStorage, BuildStorage>();
|
|
builder.Services.AddSingleton<ICommentStorage, CommentStorage>();
|
|
builder.Services.AddSingleton<IPurchaseStorage, PurchaseStorage>();
|
|
builder.Services.AddSingleton<IVendorStorage, VendorStorage>();
|
|
|
|
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
|
builder.Services.AddTransient<IVendorLogic, VendorLogic>();
|
|
builder.Services.AddTransient<IProductLogic, ProductLogic>();
|
|
builder.Services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
|
|
|
builder.Services.AddTransient<AbstractMailWorker, MailKitWorker>();
|
|
|
|
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 = "AbstractShopRestApi", Version = "v1" });
|
|
});
|
|
var app = builder.Build();
|
|
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())
|
|
});
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "AbstractShopRestApi v1"));
|
|
}
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
app.Run();
|