52 lines
1.2 KiB
C#
52 lines
1.2 KiB
C#
using BethanysPieShopHRM.Api.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddDbContext<AppDbContext>(options => {
|
|
options.UseSqlite(
|
|
builder.Configuration["ConnectionStrings:DefaultConnection"]);
|
|
});
|
|
|
|
builder.Services.AddScoped<ICountryRepository, CountryRepository>();
|
|
builder.Services.AddScoped<IJobCategoryRepository, JobCategoryRepository>();
|
|
builder.Services.AddScoped<IEmployeeRepository, EmployeeRepository>();
|
|
|
|
builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
|
|
|
builder.Services.AddCors(options =>
|
|
{
|
|
options.AddPolicy("Open", builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
|
|
});
|
|
|
|
builder.Services.AddControllers();
|
|
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseStaticFiles();
|
|
|
|
app.UseRouting();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.UseCors("Open");
|
|
|
|
app.MapControllers();
|
|
|
|
app.Run();
|