// GET: Reglage/Edit/5
 public ActionResult Edit(int id, int idProfil)
 {
     Profil profil;
     Reglage reglage;
     if ((profil = gp.Selectionner(idProfil)) != null && (reglage = profil.SelectionnerReglage(id)) != null)
     {
         ReglageViewModel model = new ReglageViewModel(reglage, idProfil);
         return View(model);
     }
     else
     {
         return HttpNotFound();
     }
 }
 // GET: Reglage/Create/5
 public ActionResult Create(int id)
 {
     if (gp.Selectionner(id) != null)
     {
         ReglageViewModel model = new ReglageViewModel()
         {
             IdProfil = id,
         };
         return View(model);
     }
     else
     {
         return HttpNotFound();
     }
 }
 public ActionResult Create(int id, ReglageViewModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             Profil p = gp.Selectionner(id);
             Reglage r = new Reglage(model);
             p.AjouterReglage(r);
             return RedirectToAction("Index", new { id });
         }
         catch(Exception ex)
         {
             ModelState.AddModelError("", "Erreur : " + ex.Message);
             return View(model);
         }
     }
     return View(model);
 }
        public ActionResult Edit(int id, ReglageViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {

                    Profil profil = gp.Lister().Single(p => p.ListerReglage().Exists(r => r.Id == id));   //TODO: Meilleur façon de faire ça?
                    Reglage reglage = new Reglage(model);
                    profil.ModifierReglage(id, reglage);
                    return RedirectToAction("Index", new { profil.Id });

                }
                catch(Exception ex)
                {
                    ModelState.AddModelError("", "Erreur : " + ex.Message);
                    return View(model);
                }
            }
            return View(model);
        }
 public ActionResult Delete(int id, ReglageViewModel model)
 {
     try
     {
         Profil profil = gp.Lister().Single(p => p.ListerReglage().Exists(r => r.Id == id));   //TODO: Meilleur façon de faire ça?
         profil.SupprimerReglage(id);
         return RedirectToAction("Index", new { profil.Id });
     }
     catch(Exception ex)
     {
         ModelState.AddModelError("", "Erreur : " + ex.Message);
         return View(model);
     }
 }
        public async void SendDataReglage(int idProfil, int idReglage, String temp, String humi, String duree = "-1", String enso = "-1")
        {
            ReglageViewModel r = new ReglageViewModel()
            {
                TemperatureInterieur = double.Parse(temp),
                Humidite = double.Parse(humi),
                Duree = int.Parse(duree),
                Lumiere = double.Parse(enso),
            };

            string content = JsonConvert.SerializeObject(r);

            var reponse = await httpc.PutAsync("/api/Reglage/" + idProfil + "/" + idReglage, new StringContent(content, Encoding.UTF8, "application/json"));
            var t = reponse;
        }