コード例 #1
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                ServiceJediClient         service = new ServiceJediClient();
                List <CaracteristiqueWCF> listCar = service.getAllCaracteristique().ToList();

                StadeWCF stadeWCF = service.getAllStade().ToList().Find(x => x.Id == id);
                stadeWCF.Planete  = collection[2];
                stadeWCF.NbPlaces = Int32.Parse(collection[3]);

                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)));
                    }
                }

                stadeWCF.Caracteristiques = listCarRes.ToArray();

                service.updateStade(stadeWCF);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #2
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                ServiceJediClient service = new ServiceJediClient();
                List<CaracteristiqueWCF> listCar = service.getAllCaracteristique().ToList();

                StadeWCF stadeWCF = service.getAllStade().ToList().Find(x => x.Id == id);
                stadeWCF.Planete = collection[2];
                stadeWCF.NbPlaces = Int32.Parse(collection[3]);

                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)));
                    }
                }

                stadeWCF.Caracteristiques = listCarRes.ToArray();

                service.updateStade(stadeWCF);
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }