Example #1
0
        public ActionResult Edit(CaracWebModel carac)
        {
            if (ModelState.IsValid)
            {
                try {
                    using (ServiceJediTournamentClient client = new ServiceJediTournamentClient()) {
                        List <CaracteristiqueWCF> list = client.getCaracs();
                        for (int i = 0; i < list.Count; i++)
                        {
                            // On remplace la caractéristique concernée
                            if (list[i].Id == carac.Id)
                            {
                                list[i] = carac.convert(carac.Id);
                                break;
                            }
                        }

                        client.updateCaracs(list);
                        client.Close();
                    }
                }
                catch {
                    TempData["error"] = "Edit error !";
                }
            }

            return(RedirectToAction("Index"));
        }
Example #2
0
        public ActionResult Create(CaracWebModel carac)
        {
            if (ModelState.IsValid)
            {
                try {
                    using (ServiceJediTournamentClient client = new ServiceJediTournamentClient()) {
                        client.newCarac(carac.convert(0));
                        client.Close();
                    }
                }
                catch {
                    TempData["error"] = "Adding error !";
                }
            }

            return(RedirectToAction("Index"));
        }