public TournoiViewModel(ServiceReference.TournoiWS tournoi) { this.Id = tournoi.Id; this.Nom = tournoi.Nom; List<MatchViewModel> tmpList = new List<MatchViewModel>(); List<JediViewModel> tmpList2 = new List<JediViewModel>(); foreach (var mat in tournoi.Matches) { tmpList.Add(new MatchViewModel(mat)); if(mat.Jedi1!=null) tmpList2.Add(new JediViewModel(mat.Jedi1)); if (mat.Jedi2 != null) tmpList2.Add(new JediViewModel(mat.Jedi2)); } this.Matches = new MatchCollection(tmpList); this.Jedis = new JediCollection(tmpList2); }
public TournoiViewModel(ServiceReference.TournoiWS tournoi) { this.Id = tournoi.Id; this.Nom = tournoi.Nom; List <MatchViewModel> tmpList = new List <MatchViewModel>(); List <JediViewModel> tmpList2 = new List <JediViewModel>(); foreach (var mat in tournoi.Matches) { tmpList.Add(new MatchViewModel(mat)); if (mat.Jedi1 != null) { tmpList2.Add(new JediViewModel(mat.Jedi1)); } if (mat.Jedi2 != null) { tmpList2.Add(new JediViewModel(mat.Jedi2)); } } this.Matches = new MatchCollection(tmpList); this.Jedis = new JediCollection(tmpList2); }
public ActionResult TournoiSelected(string tournoi) { JediCollection jedis = null; MatchCollection matches = null; using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient()) { List<MatchViewModel> tmpList = new List<MatchViewModel>(); List<JediViewModel> tmpList2 = new List<JediViewModel>(); foreach (MatchWS mat in ((TournoiWS)service.getTournois().Select(x => x.Nom == tournoi)).Matches) { tmpList.Add(new MatchViewModel(mat)); if (mat.Jedi1 != null) tmpList2.Add(new JediViewModel(mat.Jedi1)); if (mat.Jedi2 != null) tmpList2.Add(new JediViewModel(mat.Jedi2)); } matches = new MatchCollection(tmpList); jedis = new JediCollection(tmpList2); } return Json(jedis, JsonRequestBehavior.AllowGet); }