PIbd-22_Bazunov_AI_Hotel/Hotel/HotelView/Program.cs

69 lines
2.6 KiB
C#
Raw Permalink Normal View History

2023-05-19 17:52:18 +04:00
using HotelBusinessLogic.BusinessLogics;
using HotelBusinessLogic.MailWorker;
using HotelBusinessLogic.OfficePackage;
using HotelBusinessLogic.OfficePackage.Implements;
using HotelContracts.BindingModels;
using HotelContracts.BusinessLogicsContracts;
using HotelContracts.StoragesContracts;
using HotelDatabaseImplement.Implements;
using HotelView;
2023-04-06 17:22:24 +04:00
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
2023-05-19 17:52:18 +04:00
builder.Services.AddTransient<IMaitreStorage, MaitreStorage>();
builder.Services.AddTransient<IRoomStorage, RoomStorage>();
builder.Services.AddTransient<IGuestStorage, GuestStorage>();
builder.Services.AddTransient<IReservationStorage, ReservationStorage>();
builder.Services.AddTransient<ICleaningInstrumentsStorage, CleaningInstrumentsStorage>();
builder.Services.AddTransient<ICleaningStorage, CleaningStorage>();
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
builder.Services.AddTransient<IReportLogic, ReportLogic>();
builder.Services.AddTransient<ICleaningLogic, CleaningLogic>();
builder.Services.AddTransient<ICleaningInstrumentsLogic, CleaningInstrumentsLogic>();
builder.Services.AddTransient<IReservationLogic, ReservationLogic>();
builder.Services.AddTransient<IGuestLogic, GuestLogic>();
builder.Services.AddTransient<IRoomLogic, RoomLogic>();
builder.Services.AddTransient<IMaitreLogic, MaitreLogic>();
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
builder.Services.AddSingleton<Api>();
2023-04-06 17:22:24 +04:00
var app = builder.Build();
2023-05-19 17:52:18 +04:00
var mailSender = app.Services.GetService<AbstractMailWorker>();
mailSender?.MailConfig(new MailConfigBindingModel
{
MailLogin = builder.Configuration?.GetSection("MailLogin")?.Value ?? string.Empty,
MailPassword = builder.Configuration?.GetSection("MailPassword")?.Value ?? string.Empty,
SmtpClientHost = builder.Configuration?.GetSection("SmtpClientHost")?.Value ?? string.Empty,
SmtpClientPort = Convert.ToInt32(builder.Configuration?.GetSection("SmtpClientPort")?.Value),
PopHost = builder.Configuration?.GetSection("PopHost")?.Value ?? string.Empty,
PopPort = Convert.ToInt32(builder.Configuration?.GetSection("PopPort")?.Value)
});
2023-04-06 17:22:24 +04:00
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();