/// <summary> /// Demande à l'utilisateur de choisir une boisson entre Café, Chocolat et Soupe. Si la quantité de sucre et le mode de paiement sont /// déjà sélectionnés, demandera à l'utilisateur de tout valider définitivement. /// </summary> public void ChoisirBoisson() { Console.Write("Choisissez votre boisson : (1) Café, (2) Chocolat, (3) Soupe. "); try { _boissonChoisie = (Boisson)(int.Parse(Console.ReadLine()) - 1); _boissonChoisieBool = true; // Si l'utilisateur choisi une soupe, il n'y aura pas de quantité de sucre à choisir if (_boissonChoisie == Boisson.Soupe) { _quantitéSucreBool = true; } if (_paiementChoisiBool && _quantitéSucreBool) { AfficherSélction(); ValiderSélection(); } } catch (FormatException) { throw new FormatException("Cette boisson n'existe pas!"); } }
public List <Boisson> chargerBoissons() { List <Boisson> boissons = new List <Boisson>(); using (SqlConnection connexion = new SqlConnection(chaineConnexion)) { SqlCommand cmdSelectBoissons = new SqlCommand("SELECT nom, tauxAlcool FROM GC_Boisson", connexion); connexion.Open(); SqlDataReader reader = cmdSelectBoissons.ExecuteReader(); try { while (reader.Read()) { //Boisson b = new Boisson(reader["nom"].ToString(), Decimal.Parse(reader["tauxAlcool"].ToString())); Boisson b = new Boisson(reader.GetString(reader.GetOrdinal("nom")), reader.GetDecimal(reader.GetOrdinal("tauxAlcool"))); //reader.GetDecimal(1); Debug.WriteLine(String.Format("{0}, {1}", reader[0], reader[1])); boissons.Add(b); } } finally { reader.Close(); } } return(boissons); }
public ActionResult Index(MachineCafe machinecafe) { machinecafe.Boisson.ChoixList = GetBoissonListItemsFromHttpClient(); Boisson boisson = machinecafe.Boisson; int mug = machinecafe.Mug; int qtesucre = machinecafe.Qtesucre; string nom_boisson = ""; ViewBag.QteSucre = GetQtesucreListItems(); ViewBag.Mug = GetMugListItems(); if (boisson.id == 1) { nom_boisson = "Cafe"; } else if (boisson.id == 2) { nom_boisson = "The"; } else { nom_boisson = "Chocolat"; } ViewBag.commande = "Vous avez commander un " + nom_boisson + " avec " + qtesucre.ToString() + " Morceaux de sucre et " + (mug == 0 ? "Vous n'avez pas utilisé votre propre mug" : "Vous avez utilisé votre propre mug"); return(View(machinecafe)); }
public ActionResult Index() { List <Boisson> BoissonInfo = new List <Boisson>(); Boisson bn = new Boisson(); bn.ChoixList = GetBoissonListItemsFromHttpClient(); MachineCafe mc = new MachineCafe(); mc.Boisson = bn; ViewBag.QteSucre = GetQtesucreListItems(); ViewBag.Mug = GetMugListItems(); return(View(mc)); //using (var BoissonHttpClient = new HttpClient()) //{ // //Passing service base url // BoissonHttpClient.BaseAddress = new Uri(Baseurl); // BoissonHttpClient.DefaultRequestHeaders.Clear(); // //Define request data format // BoissonHttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // //Sending request to find web api REST service resource GetAllEmployees using HttpClient // HttpResponseMessage Res = await BoissonHttpClient.GetAsync("api/Boisson"); // //Checking the response is successful or not which is sent using HttpClient // if (Res.IsSuccessStatusCode) // { // //Storing the response details recieved from web api // var APIResponse = Res.Content.ReadAsStringAsync().Result; // //Deserializing the response recieved from web api and storing into the Employee list // BoissonInfo = JsonConvert.DeserializeObject<List<Boisson>>(APIResponse); // bn.ChoixList = from boissoninfo in BoissonInfo // select new SelectListItem // { // Text = boissoninfo.lib_Boisson.ToString(), // Value = ((int)boissoninfo.id).ToString() // }; // } // //***************************************** // MachineCafe mc = new MachineCafe(); // mc.Boisson = bn; // // mc.Mug = 0; // //mc.Qtesucre = 0; // ViewBag.QteSucre = GetQtesucreListItems(); // ViewBag.Mug = GetMugListItems(); // return View(mc); //} }
/// <summary> /// Initialise la machine à café avec la boisson Café, le paiement Espèces et la quantité de sucre à 3 grammes par défaut /// </summary> public MachineCafé() { Console.WriteLine("Initialisation de la machine à café."); _boissonChoisie = Boisson.Café; _paiementChoisi = Paiement.Espèces; _quantitéSucre = 3; _boissonChoisieBool = false; _paiementChoisiBool = false; _quantitéSucreBool = false; }
public List <Boisson> GetAllBoissons() { Cofe_Manager_.Data_acces.B_machinecafeEntities ctx = new B_machinecafeEntities(); T_boisson[] tb = ctx.T_boisson.ToArray(); List <Boisson> tbs = new List <Boisson>(); for (int i = 0; i < tb.Length; i++) { Boisson b = new Boisson(); b.Id = tb[i].id_boisson; b.Libelle = tb[i].libelle_b; b.Qte_sucre_recommander = tb[i].Qte_sucre_recommandation.Value; tbs.Add(b); } return(tbs); }
/// <summary> /// Bouton de validation de la suppression /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SupprimerElementsComboBox(object sender, RoutedEventArgs e) { Pizza pizza_supp = (Pizza)ComboBox_PizzasCommande.SelectedItem; Boisson boisson_supp = (Boisson)ComboBox_BoissonsCommande.SelectedItem; if (pizza_supp != null && this.pizzeria.Commandes[no_commande].Pizzas.Contains(pizza_supp)) { this.pizzeria.Commandes[no_commande].Pizzas.Remove(pizza_supp); } if (boisson_supp != null && this.pizzeria.Commandes[no_commande].Boissons.Contains(boisson_supp)) { this.pizzeria.Commandes[no_commande].Boissons.Remove(boisson_supp); } MessageBox.Show("Appuyer sur le bouton Rafraichir pour actualiser le panier."); fermer = true; this.Close(); }
public IEnumerable <SelectListItem> GetBoissonListItemsFromHttpClient() { List <Boisson> BoissonInfo = new List <Boisson>(); Boisson bn = new Boisson(); using (var BoissonHttpClient = new HttpClient()) { //Passing service base url BoissonHttpClient.BaseAddress = new Uri(Baseurl); BoissonHttpClient.DefaultRequestHeaders.Clear(); //Define request data format BoissonHttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); //Sending request to find web api REST service resource using HttpClient HttpResponseMessage Res = BoissonHttpClient.GetAsync("api/Boisson").Result; //Checking the response is successful or not which is sent using HttpClient if (Res.IsSuccessStatusCode) { //Storing the response details recieved from web api var APIResponse = Res.Content.ReadAsStringAsync().Result; //Deserializing the response recieved from web api and storing into the boisson list BoissonInfo = JsonConvert.DeserializeObject <List <Boisson> >(APIResponse); bn.ChoixList = from boissoninfo in BoissonInfo select new SelectListItem { Text = boissoninfo.lib_Boisson.ToString(), Value = ((int)boissoninfo.id).ToString() }; } return(bn.ChoixList); } }
// GET api/<controller> public IEnumerable <Boisson> Get() { List <Boisson> Lboisson = new List <Boisson>(); //conn.ConnectionString = "Server=[vulcain];Database=[MachineCafeBD]"; conn.ConnectionString = "Data Source =(LocalDB)\\MSSQLLocalDB; AttachDbFilename = C:\\Users\\gh\\source\\repos\\MachineCafe\\WebApIMachineCafe\\App_Data\\MachineCafeBD.mdf; Integrated Security = True"; conn.Open(); SqlDataReader myReader = null; SqlCommand myCommand = new SqlCommand("select * from T_boisson", conn); myReader = myCommand.ExecuteReader(); while (myReader.Read()) { Boisson boisson = new Boisson(); boisson.id = int.Parse(myReader["id"].ToString()); boisson.lib_Boisson = myReader["boisson"].ToString(); Lboisson.Add(boisson); } conn.Close(); return(Lboisson); }
public Caramel(Boisson boisson) : base(boisson) { }
public Chocolat(Boisson boisson) : base(boisson) { }
public Chantilly(Boisson boisson) : base(boisson) { }
public Lait(Boisson boisson) : base(boisson) { }