/// <summary> /// Constructor from a MatchWCF /// </summary> /// <param name="m">MatchWCF provided by the web service</param> public MatchWebModel(MatchWCF m) { Id = m.Id; Jedi1 = new JediWebModel(m.Jedi1); Jedi2 = new JediWebModel(m.Jedi2); Stade = new StadeWebModel(m.Stade); Phase = (EPhaseWeb)m.Phase; Winner = (m.Vainqueur == null) ? null : new JediWebModel(m.Vainqueur); }
/// <summary> /// Constructor from a MatchWCF /// </summary> /// <param name="m">MatchWCF provided by the web service</param> public MatchWebModel(MatchWCF m) { Id = m.Id; Jedi1 = new JediWebModel(m.Jedi1); Jedi2 = new JediWebModel(m.Jedi2); Stade = new StadeWebModel(m.Stade); Phase = (EPhaseWeb) m.Phase; Winner = (m.Vainqueur == null) ? null : new JediWebModel(m.Vainqueur); }
public ActionResult Create(JediWebModel jedi, int[] caracIds) { if (ModelState.IsValid) { try { using (ServiceJediTournamentClient client = new ServiceJediTournamentClient()) { List<CaracWebModel> caracList = new List<CaracWebModel>(); // Récupération caractéristiques si nécessaire if (caracIds != null && caracIds.Length > 0) { List<CaracteristiqueWCF> webList = client.getCaracs(); // Pour chaque caractéristique voulue foreach (int id in caracIds) { // On cherche la caractéristique correspondante foreach (CaracteristiqueWCF c in webList) { if (c.Id == id) { caracList.Add(new CaracWebModel(c)); break; } } } } // Ajout du JediWCF jedi.Caracteristiques = caracList; client.newJedi(jedi.convert()); client.Close(); } } catch { TempData["error"] = "Adding error !"; } } else { TempData["error"] = "Invalid Model !"; } return RedirectToAction("Index"); }
// GET: Jedi/Edit/5 public ActionResult Edit(int id) { JediWebModel item = null; try { using (ServiceJediTournamentClient client = new ServiceJediTournamentClient()) { List<JediWCF> webList = client.getJedis(); foreach (JediWCF j in webList) { if (j.Id == id) { item = new JediWebModel(j); break; } } if (TempData["error"] != null) { ViewData["error"] = TempData["error"]; } else { ViewData["error"] = null; } // Si on ne trouve pas le Jedi if (item == null) { throw new Exception("No way to found the jedi !"); } return PartialView(item); } } catch { return null; } }