Coursework_ComputerStore_Li.../ComputerStoreRestAPI/Program.cs

59 lines
2.1 KiB
C#

using ComputerStoreBusinessLogic.BusinessLogic;
using ComputerStoreContracts.BindingModels;
using ComputerStoreContracts.BusinessLogicContracts;
using ComputerStoreContracts.StorageContracts;
using ComputerStoreDatabaseImplement;
using ComputerStoreDatabaseImplement.Implements;
using ComputerStoreDatabaseImplement.Models;
var builder = WebApplication.CreateBuilder(args);
builder.Logging.SetMinimumLevel(LogLevel.Trace);
builder.Logging.AddLog4Net("log4net.config");
// Add services to the container.
builder.Services.AddTransient<IEmployeeStorage,EmployeeStorage>();
builder.Services.AddTransient<IComponentStorage, ComponentStorage>();
builder.Services.AddTransient<IPCStorage,PCStorage>();
builder.Services.AddTransient<IProductStorage, ProductStorage>();
builder.Services.AddTransient<IConsignmentStorage, ConsignmentStorage>();
builder.Services.AddTransient<IRequestComponentStorage, RequestComponentStorage>();
builder.Services.AddTransient<IRequestStorage, RequestStorage>();
builder.Services.AddTransient<IEmployeeLogic,EmployeeLogic>();
builder.Services.AddTransient<IComponentLogic, ComponentLogic>();
builder.Services.AddTransient<IEmployeeReportLogic, EmployeeReportLogic>();
builder.Services.AddTransient<IPCLogic, PCLogic>();
builder.Services.AddTransient<IProductLogic, ProductLogic>();
builder.Services.AddTransient<IConsignmentLogic,ConsignmentLogic>();
builder.Services.AddTransient<IRequestComponentLogic, RequestComponentLogic>();
builder.Services.AddTransient<IRequestLogic, RequestLogic>();
builder.Services.AddControllers().AddNewtonsoftJson(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();