6 Commits
0.3.0 ... 1.0.0

4 changed files with 13 additions and 4 deletions

View File

@@ -22,7 +22,8 @@ namespace PizzaExpress.Controllers
{ {
var list = await _ctx.Pizze.AsNoTracking().ToListAsync(); var list = await _ctx.Pizze.AsNoTracking().ToListAsync();
// wrapper come nell'esempio Java { "pizze": [...] } // wrapper come nell'esempio Java { "pizze": [...] }
return Ok(new { pizze = list }); //return Ok(new { pizze = list });
return Ok(list);
} }
// GET: /api/pizze/{id} (JSON o XML in base all'header Accept) // GET: /api/pizze/{id} (JSON o XML in base all'header Accept)
@@ -46,13 +47,18 @@ namespace PizzaExpress.Controllers
return NoContent(); return NoContent();
} }
// PUT: /api/pizze/{id} Body: { "prezzo": 4.70 } // PUT: /api/pizze/{id}
[HttpPut("{id:int}")] [HttpPut("{id:int}")]
public async Task<IActionResult> UpdatePrezzo(int id, [FromBody] PrezzoUpdate body) public async Task<IActionResult> UpdatePizza(int id, [FromBody] Pizza body)
{ {
var pizza = await _ctx.Pizze.FindAsync(id); var pizza = await _ctx.Pizze.FindAsync(id);
if (pizza is null) return NotFound(); if (pizza is null) return NotFound();
pizza.Nome = body.Nome;
pizza.Prezzo = body.Prezzo; pizza.Prezzo = body.Prezzo;
pizza.Categoria = body.Categoria;
pizza.Note = body.Note;
pizza.Tavolo = body.Tavolo;
pizza.Stato = body.Stato;
await _ctx.SaveChangesAsync(); await _ctx.SaveChangesAsync();
return NoContent(); return NoContent();
} }

View File

@@ -5,6 +5,9 @@
public int Id { get; set; } public int Id { get; set; }
public string Nome { get; set; } = string.Empty; public string Nome { get; set; } = string.Empty;
public decimal Prezzo { get; set; } public decimal Prezzo { get; set; }
public string Categoria { get; set; } = string.Empty;
public string Note { get; set; } = string.Empty; public string Note { get; set; } = string.Empty;
public int Tavolo { get; set; }
public string Stato { get; set; } = string.Empty;
} }
} }

View File

@@ -8,7 +8,7 @@
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
}, },
"dotnetRunMessages": true, "dotnetRunMessages": true,
"applicationUrl": "http://localhost:5011" "applicationUrl": "http://localhost:5000"
}, },
"https": { "https": {
"commandName": "Project", "commandName": "Project",

Binary file not shown.