33 lines
726 B
C#
33 lines
726 B
C#
using EmployeeLibrary.Data;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen();
|
|
builder.Services.AddSingleton<ISqlDataAccess,SqlDataAccess>();
|
|
builder.Services.AddSingleton<IEmployeeData, EmployeeData>();
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.MapGet("/employees", async (IEmployeeData db) =>
|
|
{
|
|
var output = await db.GetEmployees();
|
|
return output;
|
|
});
|
|
|
|
|
|
app.Run();
|
|
|