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

30
.dockerignore Normal file
View File

@@ -0,0 +1,30 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
!**/.gitignore
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**

54
.gitignore vendored Normal file
View File

@@ -0,0 +1,54 @@
## A streamlined .gitignore for modern .NET projects
## including temporary files, build results, and
## files generated by popular .NET tools. If you are
## developing with Visual Studio, the VS .gitignore
## https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
## has more thorough IDE-specific entries.
##
## Get latest from https://github.com/github/gitignore/blob/main/Dotnet.gitignore
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# Others
~$*
*~
CodeCoverage/
# MSBuild Binary and Structured Log
*.binlog
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,118 @@
{
"Version": 1,
"WorkspaceRootPath": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|d:\\fiorencis\\coding\\cs\\2025-10-30_pizzaexpress\\pizzaexpress\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|solutionrelative:pizzaexpress\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|d:\\fiorencis\\coding\\cs\\2025-10-30_pizzaexpress\\pizzaexpress\\controllers\\pizzecontroller.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|solutionrelative:pizzaexpress\\controllers\\pizzecontroller.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|d:\\fiorencis\\coding\\cs\\2025-10-30_pizzaexpress\\pizzaexpress\\models\\pizza.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|solutionrelative:pizzaexpress\\models\\pizza.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|d:\\fiorencis\\coding\\cs\\2025-10-30_pizzaexpress\\pizzaexpress\\weatherforecast.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|solutionrelative:pizzaexpress\\weatherforecast.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|d:\\fiorencis\\coding\\cs\\2025-10-30_pizzaexpress\\pizzaexpress\\data\\pizzacontext.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|solutionrelative:pizzaexpress\\data\\pizzacontext.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|d:\\fiorencis\\coding\\cs\\2025-10-30_pizzaexpress\\pizzaexpress\\pizzaexpress.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|",
"RelativeMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|solutionrelative:pizzaexpress\\pizzaexpress.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 2,
"Children": [
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "WeatherForecast.cs",
"DocumentMoniker": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\WeatherForecast.cs",
"RelativeDocumentMoniker": "PizzaExpress\\WeatherForecast.cs",
"ToolTip": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\WeatherForecast.cs",
"RelativeToolTip": "PizzaExpress\\WeatherForecast.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-10-30T07:41:25.868Z"
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "PizzeController.cs",
"DocumentMoniker": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\Controllers\\PizzeController.cs",
"RelativeDocumentMoniker": "PizzaExpress\\Controllers\\PizzeController.cs",
"ToolTip": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\Controllers\\PizzeController.cs",
"RelativeToolTip": "PizzaExpress\\Controllers\\PizzeController.cs",
"ViewState": "AgIAAA0AAAAAAAAAAAAgwCoAAAAxAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-10-30T07:33:25.384Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "Program.cs",
"DocumentMoniker": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\Program.cs",
"RelativeDocumentMoniker": "PizzaExpress\\Program.cs",
"ToolTip": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\Program.cs*",
"RelativeToolTip": "PizzaExpress\\Program.cs*",
"ViewState": "AgIAAAUAAAAAAAAAAAAxwBUAAAA3AAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-10-30T07:29:48.542Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "Pizza.cs",
"DocumentMoniker": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\Models\\Pizza.cs",
"RelativeDocumentMoniker": "PizzaExpress\\Models\\Pizza.cs",
"ToolTip": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\Models\\Pizza.cs",
"RelativeToolTip": "PizzaExpress\\Models\\Pizza.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAYAAAArAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-10-30T07:25:03.715Z"
},
{
"$type": "Document",
"DocumentIndex": 4,
"Title": "PizzaContext.cs",
"DocumentMoniker": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\Data\\PizzaContext.cs",
"RelativeDocumentMoniker": "PizzaExpress\\Data\\PizzaContext.cs",
"ToolTip": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\Data\\PizzaContext.cs",
"RelativeToolTip": "PizzaExpress\\Data\\PizzaContext.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAMAAAAkAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-10-30T07:22:13.507Z"
},
{
"$type": "Document",
"DocumentIndex": 5,
"Title": "PizzaExpress.csproj",
"DocumentMoniker": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\PizzaExpress.csproj",
"RelativeDocumentMoniker": "PizzaExpress\\PizzaExpress.csproj",
"ToolTip": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\PizzaExpress.csproj",
"RelativeToolTip": "PizzaExpress\\PizzaExpress.csproj",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAsAAABaAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000758|",
"WhenOpened": "2025-10-30T07:19:02.255Z"
}
]
}
]
}
]
}

View File

@@ -0,0 +1,118 @@
{
"Version": 1,
"WorkspaceRootPath": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|d:\\fiorencis\\coding\\cs\\2025-10-30_pizzaexpress\\pizzaexpress\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|solutionrelative:pizzaexpress\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|d:\\fiorencis\\coding\\cs\\2025-10-30_pizzaexpress\\pizzaexpress\\controllers\\pizzecontroller.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|solutionrelative:pizzaexpress\\controllers\\pizzecontroller.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|d:\\fiorencis\\coding\\cs\\2025-10-30_pizzaexpress\\pizzaexpress\\models\\pizza.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|solutionrelative:pizzaexpress\\models\\pizza.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|d:\\fiorencis\\coding\\cs\\2025-10-30_pizzaexpress\\pizzaexpress\\weatherforecast.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|solutionrelative:pizzaexpress\\weatherforecast.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|d:\\fiorencis\\coding\\cs\\2025-10-30_pizzaexpress\\pizzaexpress\\data\\pizzacontext.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|solutionrelative:pizzaexpress\\data\\pizzacontext.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|d:\\fiorencis\\coding\\cs\\2025-10-30_pizzaexpress\\pizzaexpress\\pizzaexpress.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|",
"RelativeMoniker": "D:0:0:{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}|PizzaExpress\\PizzaExpress.csproj|solutionrelative:pizzaexpress\\pizzaexpress.csproj||{FA3CD31E-987B-443A-9B81-186104E8DAC1}|"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 2,
"Children": [
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "WeatherForecast.cs",
"DocumentMoniker": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\WeatherForecast.cs",
"RelativeDocumentMoniker": "PizzaExpress\\WeatherForecast.cs",
"ToolTip": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\WeatherForecast.cs",
"RelativeToolTip": "PizzaExpress\\WeatherForecast.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-10-30T07:41:25.868Z"
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "PizzeController.cs",
"DocumentMoniker": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\Controllers\\PizzeController.cs",
"RelativeDocumentMoniker": "PizzaExpress\\Controllers\\PizzeController.cs",
"ToolTip": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\Controllers\\PizzeController.cs",
"RelativeToolTip": "PizzaExpress\\Controllers\\PizzeController.cs",
"ViewState": "AgIAAA0AAAAAAAAAAAAgwCoAAAAxAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-10-30T07:33:25.384Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "Program.cs",
"DocumentMoniker": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\Program.cs",
"RelativeDocumentMoniker": "PizzaExpress\\Program.cs",
"ToolTip": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\Program.cs",
"RelativeToolTip": "PizzaExpress\\Program.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAABUAAAA3AAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-10-30T07:29:48.542Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "Pizza.cs",
"DocumentMoniker": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\Models\\Pizza.cs",
"RelativeDocumentMoniker": "PizzaExpress\\Models\\Pizza.cs",
"ToolTip": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\Models\\Pizza.cs",
"RelativeToolTip": "PizzaExpress\\Models\\Pizza.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAYAAAArAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-10-30T07:25:03.715Z"
},
{
"$type": "Document",
"DocumentIndex": 4,
"Title": "PizzaContext.cs",
"DocumentMoniker": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\Data\\PizzaContext.cs",
"RelativeDocumentMoniker": "PizzaExpress\\Data\\PizzaContext.cs",
"ToolTip": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\Data\\PizzaContext.cs",
"RelativeToolTip": "PizzaExpress\\Data\\PizzaContext.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAMAAAAkAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-10-30T07:22:13.507Z"
},
{
"$type": "Document",
"DocumentIndex": 5,
"Title": "PizzaExpress.csproj",
"DocumentMoniker": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\PizzaExpress.csproj",
"RelativeDocumentMoniker": "PizzaExpress\\PizzaExpress.csproj",
"ToolTip": "D:\\Fiorencis\\Coding\\Cs\\2025-10-30_PizzaExpress\\PizzaExpress\\PizzaExpress.csproj",
"RelativeToolTip": "PizzaExpress\\PizzaExpress.csproj",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAsAAABaAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000758|",
"WhenOpened": "2025-10-30T07:19:02.255Z"
}
]
}
]
}
]
}

View File

@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35312.102
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PizzaExpress", "PizzaExpress\PizzaExpress.csproj", "{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EEE7EBCE-8025-4BB8-BED0-0BC734CB00BF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {50EB03E5-146C-4173-A354-9BF8FB8A264A}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,76 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using PizzaExpress.Data;
using PizzaExpress.Models;
namespace PizzaExpress.Controllers
{
[ApiController]
[Route("api/pizze")]
public class PizzeController : ControllerBase
{
private readonly PizzaContext _ctx;
public PizzeController(PizzaContext ctx)
{
_ctx = ctx;
}
// GET: /api/pizze
[HttpGet]
[Produces("application/json", "text/xml")]
public async Task<ActionResult<object>> GetPizze()
{
var list = await _ctx.Pizze.AsNoTracking().ToListAsync();
// wrapper come nell'esempio Java { "pizze": [...] }
return Ok(new { pizze = list });
}
// GET: /api/pizze/{id} (JSON o XML in base all'header Accept)
[HttpGet("{id:int}")]
[Produces("application/json", "text/xml")]
public async Task<IActionResult> GetPizzaById(int id)
{
var pizza = await _ctx.Pizze.AsNoTracking().FirstOrDefaultAsync(p => p.Id == id);
if (pizza is null) return NotFound();
return Ok(pizza);
}
// DELETE: /api/pizze/{id}
[HttpDelete("{id:int}")]
public async Task<IActionResult> DeletePizza(int id)
{
var pizza = await _ctx.Pizze.FindAsync(id);
if (pizza is null) return NotFound();
_ctx.Pizze.Remove(pizza);
await _ctx.SaveChangesAsync();
return NoContent();
}
// PUT: /api/pizze/{id} Body: { "prezzo": 4.70 }
[HttpPut("{id:int}")]
public async Task<IActionResult> UpdatePrezzo(int id, [FromBody] PrezzoUpdate body)
{
var pizza = await _ctx.Pizze.FindAsync(id);
if (pizza is null) return NotFound();
pizza.Prezzo = body.Prezzo;
await _ctx.SaveChangesAsync();
return NoContent();
}
// POST: /api/pizze Body: { "id":4, "nome":"della casa", "prezzo": 8.50 }
[HttpPost]
public async Task<IActionResult> AddPizza([FromBody] Pizza p)
{
var exists = await _ctx.Pizze.AnyAsync(x => x.Id == p.Id);
if (exists) return BadRequest("ID già esistente.");
_ctx.Pizze.Add(p);
await _ctx.SaveChangesAsync();
return CreatedAtAction(nameof(GetPizzaById), new { id = p.Id }, p);
}
public class PrezzoUpdate
{
public decimal Prezzo { get; set; }
}
}
}

View File

@@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Mvc;
namespace PizzaExpress.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
}

View File

@@ -0,0 +1,31 @@
// No, qui non troverai IIDX Sparkle Shower
// wait for chinese leakers
using PizzaExpress.Models;
using Microsoft.EntityFrameworkCore;
namespace PizzaExpress.Data
{
public class PizzaContext : DbContext
{
public PizzaContext(DbContextOptions<PizzaContext> options)
: base(options) { }
public DbSet<Pizza> Pizze => Set<Pizza>();
}
public static class SeedData
{
public static void Initialize(PizzaContext ctx)
{
if (ctx.Pizze.Any()) return;
ctx.Pizze.AddRange(
new Pizza { Id = 1, Nome = "Margherita", Prezzo = 4.50m },
new Pizza { Id = 2, Nome = "Prosciutto", Prezzo = 5.00m },
new Pizza { Id = 3, Nome = "Capricciosa", Prezzo = 7.00m }
);
ctx.SaveChanges();
}
}
}

30
PizzaExpress/Dockerfile Normal file
View File

@@ -0,0 +1,30 @@
# Vedere https://aka.ms/customizecontainer per informazioni su come personalizzare il contenitore di debug e su come Visual Studio usa questo Dockerfile per compilare le immagini per un debug più rapido.
# Questa fase viene usata durante l'esecuzione da Visual Studio in modalità rapida (impostazione predefinita per la configurazione di debug)
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
# Questa fase viene usata per compilare il progetto di servizio
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["PizzaExpress/PizzaExpress.csproj", "PizzaExpress/"]
RUN dotnet restore "./PizzaExpress/PizzaExpress.csproj"
COPY . .
WORKDIR "/src/PizzaExpress"
RUN dotnet build "./PizzaExpress.csproj" -c $BUILD_CONFIGURATION -o /app/build
# Questa fase viene usata per pubblicare il progetto di servizio da copiare nella fase finale
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./PizzaExpress.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
# Questa fase viene usata nell'ambiente di produzione o durante l'esecuzione da Visual Studio in modalità normale (impostazione predefinita quando non si usa la configurazione di debug)
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "PizzaExpress.dll"]

View File

@@ -0,0 +1,9 @@
namespace PizzaExpress.Models
{
public class Pizza
{
public int Id { get; set; }
public string Nome { get; set; } = string.Empty;
public decimal Prezzo { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>d99fa37d-ba8c-4bba-9c32-705cde4708c6</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.10" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>http</ActiveDebugProfile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,6 @@
@PizzaExpress_HostAddress = http://localhost:5011
GET {{PizzaExpress_HostAddress}}/weatherforecast/
Accept: application/json
###

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();
}
}
}

View File

@@ -0,0 +1,52 @@
{
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5011"
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7297;http://localhost:5011"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Container (Dockerfile)": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"environmentVariables": {
"ASPNETCORE_HTTPS_PORTS": "8081",
"ASPNETCORE_HTTP_PORTS": "8080"
},
"publishAllPorts": true,
"useSSL": true
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:52949",
"sslPort": 44362
}
}
}

View File

@@ -0,0 +1,13 @@
namespace PizzaExpress
{
public class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}