Cristo bastardo

This commit is contained in:
2025-11-17 13:06:14 +01:00
commit e46c78fefd
35 changed files with 1716 additions and 0 deletions

62
PizzaExpress/Program.cs Normal file
View File

@@ -0,0 +1,62 @@
using Microsoft.EntityFrameworkCore;
using PizzaExpress.Data;
namespace PizzaExpress
{
public class Program
{
public static void Main(string[] args)
{
var MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddCors(options =>
{
options.AddPolicy(name: MyAllowSpecificOrigins,
policy =>
{
policy.WithOrigins("http://127.0.0.1:5500",
"http://localhost:5500")
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials();
});
});
// Add services to the container.
builder.Services.AddControllers()
.AddXmlSerializerFormatters();
// DB in memory perch<63> siamo froci
builder.Services.AddDbContext<PizzaContext>(opt =>
opt.UseInMemoryDatabase("dbpizze"));
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
using (var porcoidddioooo = app.Services.CreateScope())
{
var ctx = porcoidddioooo.ServiceProvider.GetRequiredService<PizzaContext>();
SeedData.Initialize(ctx);
}
app.UseSwagger();
app.UseSwaggerUI();
app.UseHttpsRedirection();
app.UseCors(MyAllowSpecificOrigins);
app.UseAuthorization();
app.MapControllers();
app.Run();
}
}
}