Add project files.
This commit is contained in:
32
EmployeeApi/Program.cs
Normal file
32
EmployeeApi/Program.cs
Normal file
@ -0,0 +1,32 @@
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user