2024-05-25 23:32:30 +04:00
|
|
|
using DiningRoomBusinessLogic.BusinessLogic;
|
2024-08-27 04:03:48 +04:00
|
|
|
using DiningRoomBusinessLogic.MailWorker;
|
|
|
|
|
|
|
|
//using DiningRoomBusinessLogic.MailWorker;
|
|
|
|
using DiningRoomBusinessLogic.OfficePackage;
|
|
|
|
using DiningRoomBusinessLogic.OfficePackage.Implements;
|
|
|
|
using DiningRoomContracts.BindingModels;
|
2024-05-04 21:33:24 +04:00
|
|
|
using DiningRoomContracts.BusinessLogicContracts;
|
|
|
|
using DiningRoomContracts.StorageContracts;
|
|
|
|
using DiningRoomDatabaseImplement.Implements;
|
|
|
|
using Microsoft.OpenApi.Models;
|
|
|
|
|
2024-08-27 04:03:48 +04:00
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
2024-05-04 21:33:24 +04:00
|
|
|
|
2024-08-27 04:03:48 +04:00
|
|
|
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
|
|
|
// Add services to the container.
|
2024-05-04 21:33:24 +04:00
|
|
|
|
2024-08-27 04:03:48 +04:00
|
|
|
builder.Services.AddTransient<IComponentStorage, ComponentStorage>();
|
|
|
|
builder.Services.AddTransient<IProductStorage, ProductStorage>();
|
|
|
|
builder.Services.AddTransient<IDrinkStorage, DrinkStorage>();
|
|
|
|
builder.Services.AddTransient<ICardStorage, CardStorage>();
|
|
|
|
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
|
|
|
builder.Services.AddTransient<IUserStorage, UserStorage>();
|
2024-05-04 21:33:24 +04:00
|
|
|
|
2024-08-27 04:03:48 +04:00
|
|
|
builder.Services.AddTransient<IComponentLogic, ComponentLogic>();
|
|
|
|
builder.Services.AddTransient<IProductLogic, ProductLogic>();
|
|
|
|
builder.Services.AddTransient<IDrinkLogic, DrinkLogic>();
|
|
|
|
builder.Services.AddTransient<ICardLogic, CardLogic>();
|
|
|
|
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
|
|
|
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
2024-05-04 21:33:24 +04:00
|
|
|
|
2024-08-27 04:03:48 +04:00
|
|
|
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
|
|
|
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
|
|
|
builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
|
|
|
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
|
|
|
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
2024-05-04 21:33:24 +04:00
|
|
|
|
|
|
|
|
2024-08-27 04:03:48 +04:00
|
|
|
builder.Services.AddControllers();
|
|
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
|
|
builder.Services.AddSwaggerGen(c =>
|
2024-05-04 21:33:24 +04:00
|
|
|
{
|
|
|
|
c.SwaggerDoc("v1", new OpenApiInfo
|
|
|
|
{
|
|
|
|
Title = "DiningRoomRestApi",
|
|
|
|
Version = "v1"
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2024-08-27 04:03:48 +04:00
|
|
|
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())
|
|
|
|
});
|
2024-05-04 21:33:24 +04:00
|
|
|
|
2024-08-27 04:03:48 +04:00
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
if (app.Environment.IsDevelopment())
|
2024-05-04 21:33:24 +04:00
|
|
|
{
|
2024-08-27 04:03:48 +04:00
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "DiningRoomRestApi v1"));
|
2024-05-04 21:33:24 +04:00
|
|
|
}
|
|
|
|
|
2024-08-27 04:03:48 +04:00
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
app.Run();
|