public ActionResult Edit(int id, FormCollection collection) { try { ServiceJediClient service = new ServiceJediClient(); List <CaracteristiqueWCF> listCar = service.getAllCaracteristique().ToList(); JediWCF jediWCF = service.getAllJedi().ToList().Find(x => x.Id == id); jediWCF.Nom = collection[2]; jediWCF.IsSith = collection[3].StartsWith("true"); List <CaracteristiqueWCF> listCarRes = new List <CaracteristiqueWCF>(); char[] delimiterChars = { ',' }; string[] caractStr = collection[4].Split(delimiterChars); foreach (string str in caractStr) { if (str != "false") { listCarRes.Add(listCar.Find(x => x.Id == Int32.Parse(str))); } } jediWCF.Caracteristiques = listCarRes.ToArray(); service.updateJedi(jediWCF); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, FormCollection collection) { try { ServiceJediClient service = new ServiceJediClient(); List<CaracteristiqueWCF> listCar = service.getAllCaracteristique().ToList(); JediWCF jediWCF = service.getAllJedi().ToList().Find(x => x.Id == id); jediWCF.Nom = collection[2]; jediWCF.IsSith = collection[3].StartsWith("true"); List<CaracteristiqueWCF> listCarRes = new List<CaracteristiqueWCF>(); char[] delimiterChars = { ',' }; string[] caractStr = collection[4].Split(delimiterChars); foreach (string str in caractStr) { if (str != "false") { listCarRes.Add(listCar.Find(x => x.Id == Int32.Parse(str))); } } jediWCF.Caracteristiques = listCarRes.ToArray(); service.updateJedi(jediWCF); return RedirectToAction("Index"); } catch { return View(); } }