PIbd-21_MasenkinMS_Coursewo.../Hospital/HospitalRestApi/Program.cs
2024-04-30 18:43:06 +04:00

62 lines
2.2 KiB
C#

using HospitalBusinessLogics.BusinessLogics;
using HospitalBusinessLogics.OfficePackage.Implements;
using HospitalBusinessLogics.OfficePackage;
using HospitalContracts.BusinessLogicsContracts;
using HospitalContracts.StoragesContracts;
using HospitalDatabaseImplement.Implements;
using Microsoft.OpenApi.Models;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// Logger service
builder.Logging.SetMinimumLevel(LogLevel.Trace);
builder.Logging.AddLog4Net("log4net.config");
// Storage services
builder.Services.AddTransient<IDoctorStorage, DoctorStorage>();
builder.Services.AddTransient<IPatientStorage, PatientStorage>();
builder.Services.AddTransient<IRecipeStorage, RecipeStorage>();
builder.Services.AddTransient<IDiseaseStorage, DiseaseStorage>();
builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
builder.Services.AddTransient<IMedicineStorage, MedicineStorage>();
// BusinessLogic services
builder.Services.AddTransient<IDoctorLogic, DoctorLogic>();
builder.Services.AddTransient<IPatientLogic, PatientLogic>();
builder.Services.AddTransient<IRecipeLogic, RecipeLogic>();
builder.Services.AddTransient<IDiseaseLogic, DiseaseLogic>();
builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>();
builder.Services.AddTransient<IMedicineLogic, MedicineLogic>();
// BusinessLogic Reports services
builder.Services.AddTransient<IReportLogic, ReportLogic>();
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
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();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "HospitalRestApi v1"));
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();