90 lines
3.5 KiB
C#
Raw Permalink Normal View History

using BankBusinessLogic.BusinessLogics.Cashier;
using BankBusinessLogic.BusinessLogics.Client;
using BankBusinessLogic.BusinessLogics.Reports;
using BankBusinessLogic.MailWorker;
using BankBusinessLogic.OfficePackage;
using BankBusinessLogic.OfficePackage.Implements;
using BankContracts.BindingModels.Messages;
using BankContracts.BusinessLogicsContracts.Cashier;
using BankContracts.BusinessLogicsContracts.Client;
using BankContracts.BusinessLogicsContracts.Reports;
using BankContracts.StoragesContracts.Cashier;
using BankContracts.StoragesContracts.Client;
using BankDatabaseImplement.Implements;
using BankDatabaseImplement.Implements.CashierImplements;
using BankDatabaseImplement.Implements.ClientImplements;
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<ICashierStorage, CashierStorage>();
builder.Services.AddTransient<IAccountStorage, AccountStorage>();
builder.Services.AddTransient<ICardStorage, CardStorage>();
builder.Services.AddTransient<ICreditingStorage, CreditingStorage>();
builder.Services.AddTransient<IMoneyTransferStorage, MoneyTransferStorage>();
builder.Services.AddTransient<IDebitingStorage, DebitingStorage>();
builder.Services.AddTransient<ICashWithdrawalStorage, CashWithdrawalStorage>();
builder.Services.AddTransient<IClientLogic, ClientLogic>();
builder.Services.AddTransient<ICashierLogic, CashierLogic>();
builder.Services.AddTransient<IAccountLogic, AccountLogic>();
builder.Services.AddTransient<ICardLogic, CardLogic>();
builder.Services.AddTransient<ICreditingLogic, CreditingLogic>();
builder.Services.AddTransient<IMoneyTransferLogic, MoneyTransferLogic>();
builder.Services.AddTransient<IDebitingLogic, DebitingLogic>();
builder.Services.AddTransient<ICashWithdrawalLogic, CashWithdrawalLogic>();
builder.Services.AddTransient<IReportClientLogic, ReportClientLogic>();
builder.Services.AddSingleton<IReportCashierLogic, ReportCashierLogic>();
builder.Services.AddSingleton<MailKitWorker>();
//<2F><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
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 = "BankRestAPI", Version = "v1" });
});
var app = builder.Build();
//Mails Service
var mailSender = app.Services.GetService<MailKitWorker>();
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()),
});
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "BankRestAPI v1"));
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();