73 lines
3.2 KiB
C#
73 lines
3.2 KiB
C#
using TravelAgencyBusinessLogic.BusinessLogics;
|
|
using TravelAgencyBusinessLogic.OfficePackage.Implements;
|
|
using TravelAgencyBusinessLogic.OfficePackage;
|
|
using TravelAgencyContracts.BusinessLogicsContracts;
|
|
using TravelAgencyContracts.StoragesContracts;
|
|
using TravelAgencyDatabaseImplement.Implements;
|
|
using TravelAgencyWebApp;
|
|
using TravelAgencyBusinessLogic.MailWorker;
|
|
|
|
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
// Add services to the container.
|
|
builder.Services.AddControllersWithViews();
|
|
|
|
builder.Services.AddTransient<IUserStorage, UserStorage>();
|
|
builder.Services.AddTransient<ITourStorage, TourStorage>();
|
|
builder.Services.AddTransient<IExcursionStorage, ExcursionStorage>();
|
|
builder.Services.AddTransient<IExcursionGroupStorage, ExcursionGroupStorage>();
|
|
builder.Services.AddTransient<IGuideStorage, GuideStorage>();
|
|
builder.Services.AddTransient<IPlaceStorage, PlaceStorage>();
|
|
builder.Services.AddTransient<ITripStorage, TripStorage>();
|
|
|
|
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
|
builder.Services.AddTransient<ITourLogic, TourLogic>();
|
|
builder.Services.AddTransient<IExcursionLogic, ExcursionLogic>();
|
|
builder.Services.AddTransient<IExcursionGroupLogic, ExcursionGroupLogic>();
|
|
builder.Services.AddTransient<IGuideLogic, GuideLogic>();
|
|
builder.Services.AddTransient<IPlaceLogic, PlaceLogic>();
|
|
builder.Services.AddTransient<ITripLogic, TripLogic>();
|
|
|
|
builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
|
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
|
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
|
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
|
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
|
|
|
var app = builder.Build();
|
|
|
|
var mailSender = app.Services.GetService<AbstractMailWorker>();
|
|
mailSender?.MailConfig(new()
|
|
{
|
|
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())
|
|
|
|
});
|
|
|
|
var guideLogic = app.Services.GetService<IGuideLogic>();
|
|
var tripLogic = app.Services.GetService<ITripLogic>();
|
|
var placeLogic = app.Services.GetService<IPlaceLogic>();
|
|
|
|
var seeder = new SeedingService(guideLogic, tripLogic, placeLogic);
|
|
seeder.SeedGuarantor();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Home/Error");
|
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
app.UseHsts();
|
|
}
|
|
app.UseHttpsRedirection();
|
|
app.UseStaticFiles();
|
|
app.UseRouting();
|
|
app.UseAuthorization();
|
|
app.MapControllerRoute(
|
|
name: "default",
|
|
pattern: "{controller=Home}/{action=Index}/{id?}");
|
|
app.Run(); |