//RECHER DE PLAT POUR LA SELECTION public List <Plat> RechercheDePlat(BDD bdd, List <Plat> listePlats) { int saisie = 0; while (saisie == 0) { Console.WriteLine("Tapez le nom du plat que vous recherchez: \n"); string selection1 = Console.ReadLine(); List <Plat> RecherchePLat = bdd.RechercherPlat(selection1); foreach (Plat p in RecherchePLat) { p.AffichageClient(); Console.WriteLine("__________________"); } Console.WriteLine("0 : Recommencer ma recherche \n1 : Saisir l'ID du plat que je souhaite commander "); saisie = Convert.ToInt32(Console.ReadLine()); } Console.WriteLine("ID :"); string id = Console.ReadLine(); Console.WriteLine("Quantité : "); int quantite = Convert.ToInt32(Console.ReadLine()); List <Plat> toutLesPlats = bdd.GetPlats(); if (bdd.Cuisinable(id, quantite)) { foreach (Plat p in toutLesPlats) { if (Convert.ToString(p.IdPlat) == id) { for (int i = 0; i < quantite; i++) { listePlats.Add(p); } } } } else { Console.WriteLine("Ce plat avec les QUANTITES choisis n'est pas disponible, veuillez nous excusez..."); int quantitePossible = 0; for (int i = quantite - 1; i == 0; i--) { if (bdd.Cuisinable(id, i)) { quantitePossible = i; } } if (quantitePossible != 0) { Console.WriteLine("\nCependant le plat choisi est cuisinale pour une quantité de " + Convert.ToString(quantitePossible)); } } return(listePlats); }
// SELECTION DE PLAT public List <Plat> SelectionPlats(BDD bdd) { int choix = 1; List <Plat> plats = new List <Plat>(); while (choix != 3) { Console.WriteLine("1 : Rechercher un plat \n2 : Parcourir la liste des plats \n3 : Valider la commande\n"); Console.WriteLine(" Veuillez saisir votre choix : "); choix = Convert.ToInt32(Console.ReadLine()); switch (choix) { case 1: plats = RechercheDePlat(bdd, plats); Console.WriteLine("\nVOTRE PLAT A ETE AJOUTE AVEC SUCCES !\n"); break; case 2: Console.WriteLine(" Voici les plats disponibles"); List <Plat> toutlesplats = bdd.GetPlats(); foreach (Plat p in toutlesplats) { if (bdd.Cuisinable(Convert.ToString(p.IdPlat), 1)) { p.AffichageClient(); } } Console.WriteLine("Veuillez saisir l'ID du plat choisi ainsi que sa quantité "); Console.WriteLine("ID : "); string id = Console.ReadLine(); Console.WriteLine("Quantité : "); int quantite = Convert.ToInt32(Console.ReadLine()); if (bdd.Cuisinable(id, quantite)) { foreach (Plat p in toutlesplats) { if (Convert.ToString(p.IdPlat) == id) { for (int i = 0; i < quantite; i++) { plats.Add(p); } } } Console.WriteLine("\nVOTRE PLAT A ETE AJOUTE AVEC SUCCES !\n"); //bdd.ActualisationStock(id, quantite); } else { Console.WriteLine("Ce plat avec les QUANTITES choisis n'est pas disponible, veuillez nous excusez..."); int quantitePossible = 0; for (int i = quantite - 1; i == 0; i--) { if (bdd.Cuisinable(id, i)) { quantitePossible = i; } } if (quantitePossible != 0) { Console.WriteLine("\nCependant le plat choisi est cuisinale pour une quantité de " + Convert.ToString(quantitePossible)); } } break; case 3: break; } } return(plats); }