2023-05-17 17:48:12 +04:00
|
|
|
|
using HospitalBusinessLogic;
|
2023-05-19 08:30:36 +04:00
|
|
|
|
using HospitalBusinessLogic.MailWorker;
|
2023-05-18 18:23:17 +04:00
|
|
|
|
using HospitalBusinessLogic.OfficePackage;
|
|
|
|
|
using HospitalBusinessLogic.OfficePackage.Implements;
|
2023-05-19 08:30:36 +04:00
|
|
|
|
using HospitalContracts.BindingModels;
|
2023-05-17 17:48:12 +04:00
|
|
|
|
using HospitalContracts.BusinessLogicContracts;
|
|
|
|
|
using HospitalContracts.StorageContracts;
|
2023-05-19 10:53:52 +04:00
|
|
|
|
using HospitalDatabaseImplement;
|
2023-05-17 17:48:12 +04:00
|
|
|
|
using HospitalDatabaseImplement.Implements;
|
|
|
|
|
using Microsoft.OpenApi.Models;
|
|
|
|
|
|
2023-05-19 08:30:36 +04:00
|
|
|
|
|
2023-05-17 17:48:12 +04:00
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
|
|
|
// Add services to the container.
|
|
|
|
|
builder.Services.AddTransient<IApothecaryStorage, ApothecaryStorage>();
|
|
|
|
|
builder.Services.AddTransient<IMedicineStorage, MedicineStorage>();
|
|
|
|
|
builder.Services.AddTransient<IPrescriptionStorage, PrescriptionStorage>();
|
|
|
|
|
builder.Services.AddTransient<IRecipeStorage, RecipeStorage>();
|
|
|
|
|
|
|
|
|
|
builder.Services.AddTransient<IPatientStorage, PatientStorage>();
|
|
|
|
|
builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
|
|
|
|
|
builder.Services.AddTransient<ITreatmentStorage, TreatmentStorage>();
|
|
|
|
|
|
|
|
|
|
builder.Services.AddTransient<IApothecaryLogic, ApothecaryLogic>();
|
|
|
|
|
builder.Services.AddTransient<IMedicineLogic, MedicineLogic>();
|
|
|
|
|
builder.Services.AddTransient<IPrescriptionLogic, PrescriptionLogic>();
|
|
|
|
|
builder.Services.AddTransient<IRecipeLogic, RecipeLogic>();
|
|
|
|
|
|
|
|
|
|
builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>();
|
|
|
|
|
builder.Services.AddTransient<ITreatmentLogic, TreatmentLogic>();
|
|
|
|
|
|
|
|
|
|
builder.Services.AddTransient<IReportLogic, ReportLogic>();
|
|
|
|
|
|
2023-05-18 18:23:17 +04:00
|
|
|
|
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
|
|
|
|
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
|
|
|
|
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
2023-05-19 08:30:36 +04:00
|
|
|
|
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
2023-05-17 17:48:12 +04:00
|
|
|
|
|
|
|
|
|
builder.Services.AddControllers().AddJsonOptions((option) =>
|
|
|
|
|
{
|
|
|
|
|
option.JsonSerializerOptions.IncludeFields = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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"
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2023-05-19 08:30:36 +04:00
|
|
|
|
|
2023-05-17 17:48:12 +04:00
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
2023-05-19 08:30:36 +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()),
|
|
|
|
|
});
|
2023-05-19 10:53:52 +04:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
|
|
|
|
|
LoaderFromXML.LoadProcedures();
|
|
|
|
|
LoaderFromXML.LoadTreatments();
|
|
|
|
|
LoaderFromXML.LoadPatients();
|
2023-05-17 17:48:12 +04:00
|
|
|
|
// 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();
|