Implementazione funzione ingredienti per Server 1.0.1
This commit is contained in:
@@ -367,7 +367,7 @@ namespace PizzaExpress_Client
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
private void BtnIngredienti_Click(object? sender, EventArgs e)
|
||||
private async void BtnIngredienti_Click(object? sender, EventArgs e)
|
||||
{
|
||||
if (_lstPizze.SelectedItem == null)
|
||||
{
|
||||
@@ -375,7 +375,32 @@ namespace PizzaExpress_Client
|
||||
return;
|
||||
}
|
||||
|
||||
MessageBox.Show("Funzionalità Ingredienti non ancora implementata.");
|
||||
var pizza = _tutteLePizze[_lstPizze.SelectedIndex];
|
||||
|
||||
try
|
||||
{
|
||||
var dati = await _httpClient.GetFromJsonAsync<RispostaIngredienti>($"api/ingredienti/da-pizza?nome={pizza.Nome}");
|
||||
|
||||
if (dati == null)
|
||||
{
|
||||
MessageBox.Show("Errore nella risposta del server.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (dati.ingredienti.Count == 0)
|
||||
{
|
||||
MessageBox.Show($"La pizza {dati.pizza} non ha ingredienti associati.");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"Ingredienti {dati.pizza}:\n- " + string.Join("\n- ", dati.ingredienti));
|
||||
}
|
||||
}
|
||||
catch (Exception nigga)
|
||||
{
|
||||
MessageBox.Show($"{nigga.Message}", "Errore nella richiesta", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void PulisciCampi()
|
||||
|
||||
15
RispostaIngredienti.cs
Normal file
15
RispostaIngredienti.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PizzaExpress_Client
|
||||
{
|
||||
internal class RispostaIngredienti
|
||||
{
|
||||
public string pizza { get; set; }
|
||||
public List<string> ingredienti { get; set; }
|
||||
public string fonte { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user