85 lines
3.2 KiB
C#
Raw Normal View History

2023-04-07 01:21:27 +04:00
using HospitalBusinessLogic.BusinessLogics;
2023-06-21 23:38:26 +04:00
using HospitalBusinessLogic.MailWorker;
using HospitalBusinessLogic.OfficePackage;
using HospitalBusinessLogic.OfficePackage.Implements;
2023-06-21 23:38:26 +04:00
using HospitalContracts.BindingModels;
2023-04-07 01:21:27 +04:00
using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.StoragesContracts;
using HospitalDataBaseImplements;
2023-04-07 01:21:27 +04:00
using HospitalDataBaseImplements.Implements;
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>();
2023-05-20 06:49:33 +04:00
builder.Services.AddTransient<IKurseStorage, KurseStorage>();
2023-04-07 01:21:27 +04:00
builder.Services.AddTransient<IIllnessStorage, IllnessStorage>();
builder.Services.AddTransient<ISymptomsStorage, SymptomsStorage>();
builder.Services.AddTransient<IMedicinesStorage, MedicinesStorage>();
builder.Services.AddTransient<IProceduresStorage, ProceduresStorage>();
builder.Services.AddTransient<IRecipesStorage, RecipesStorage>();
builder.Services.AddTransient<IClientLogic, ClientLogic>();
builder.Services.AddTransient<IIllnessLogic, IllnessLogic>();
builder.Services.AddTransient<ISymptomsLogic, SymptomsLogic>();
builder.Services.AddTransient<IMedicinesLogic, MedicinesLogic>();
builder.Services.AddTransient<IProceduresLogic, ProceduresLogic>();
2023-05-20 06:49:33 +04:00
builder.Services.AddTransient<IKurseLogic, KurseLogic>();
2023-04-07 01:21:27 +04:00
builder.Services.AddTransient<IRecipesLogic, RecipesLogic>();
builder.Services.AddTransient<IReportLogic, ReportLogic>();
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
2023-04-07 01:21:27 +04:00
2023-06-21 23:38:26 +04:00
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
2023-04-07 01:21:27 +04:00
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 = "HospitalRestApi",
Version
= "v1"
});
});
var app = builder.Build();
LoaderFromXML.LoadSymptoms();
LoaderFromXML.LoadKurses();
2023-04-07 01:21:27 +04:00
2023-06-21 23:38:26 +04:00
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())
});
2023-04-07 01:21:27 +04:00
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
2023-05-20 06:49:33 +04:00
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json","HospitalRestApi v1"));
2023-04-07 01:21:27 +04:00
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();