コード例 #1
0
        public void TestServiceGetMatches()
        {
            ServiceReference.ServiceClient client = new ServiceReference.ServiceClient();
            List <MatchWS> matches = client.getMatches();

            Assert.IsNotNull(matches);
            MatchWS combat = matches.Find(x => x.Jedi1.Nom.Equals("Obi Wan Kenobi") && x.Jedi2.Nom.Equals("Yoda"));

            Assert.IsNotNull(combat);
            client.Close();
        }
コード例 #2
0
        public void TestServiceUpdateMatches()
        {
            ServiceReference.ServiceClient client = new ServiceReference.ServiceClient();

            List <MatchWS> matches = client.getMatches();

            Assert.IsNotNull(matches);
            MatchWS kamino = client.getMatches().Find(x => x.Id.Equals(11));

            kamino.Phase = (EPhaseTournoiWS)5;
            client.updateMatch(kamino);
            Assert.AreEqual((EPhaseTournoiWS)5, ((MatchWS)client.getMatches().Find(x => x.Id.Equals(11))).Phase);
            kamino.Phase = (EPhaseTournoiWS)4;
            client.updateMatch(kamino);
            Assert.AreEqual((EPhaseTournoiWS)4, ((MatchWS)client.getMatches().Find(x => x.Id.Equals(11))).Phase);

            client.Close();
        }
コード例 #3
0
        public void TestServiceARMatches()
        {
            ServiceReference.ServiceClient client = new ServiceReference.ServiceClient();

            List <MatchWS> matches = client.getMatches();
            List <JediWS>  jedis   = client.getJedis();
            List <StadeWS> stades  = client.getStades();
            int            size    = matches.Count;

            Assert.IsNotNull(matches);
            /* AJOUT */
            MatchWS zone = new MatchWS(0, jedis.ElementAt(0), jedis.ElementAt(3), null, stades.ElementAt(0), EntitiesLayer.EPhaseTournoi.HuitiemeFinale1);

            client.addMatch(zone);
            Assert.AreEqual(size + 1, client.getMatches().Count);
            /* SUPPRESSION */
            zone = client.getMatches().Find(x => x.Jedi1 != null && x.Jedi2 != null && x.Jedi1.Id.Equals(jedis.ElementAt(0).Id) && x.Jedi2.Id.Equals(jedis.ElementAt(3).Id) && x.Stade.Id.Equals(stades.ElementAt(0).Id));
            client.removeMatch(zone);
            Assert.AreEqual(size, client.getMatches().Count);

            client.Close();
        }
コード例 #4
0
        public ActionResult Create(FormCollection collection)
        {
            //try {
            ServiceReference.TournoiWS tournoi = new ServiceReference.TournoiWS();
            List <JediWS>  jediList            = new List <JediWS>();
            List <StadeWS> stadeList           = new List <StadeWS>();

            using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient())
            {
                service.getJedis().ForEach(x => jediList.Add(x));
                service.getStades().ForEach(x => stadeList.Add(x));

                tournoi.Id      = 0;
                tournoi.Nom     = Convert.ToString(collection.Get("Item1.Nom"));
                tournoi.Matches = new List <MatchWS>();

                // Va chercher jedi1, jedi2 et stade pour les huitieme
                for (int i = (int)EPhaseTournoiWS.HuitiemeFinale1; i >= (int)EPhaseTournoiWS.HuitiemeFinale8; i--)
                {
                    MatchWS m = new MatchWS();
                    m.Id            = 0;
                    m.JediVainqueur = null;
                    m.Phase         = ((EPhaseTournoiWS)i);
                    m.Stade         = stadeList.First(x => x.Id == Convert.ToInt32(collection.Get("stadefor" + i)));
                    m.Jedi1         = jediList.First(x => x.Id == Convert.ToInt32(collection.Get("jedi1for" + i)));
                    m.Jedi2         = jediList.First(x => x.Id == Convert.ToInt32(collection.Get("jedi2for" + i)));
                    tournoi.Matches.Add(m);
                    // TODO : ai-je besoin des participants ?
                }

                // Va chercher stade pour les autres phases
                for (int i = (int)EPhaseTournoiWS.QuartFinale1; i >= (int)EPhaseTournoiWS.Finale; i--)
                {
                    MatchWS m = new MatchWS();
                    m.Id            = 0;
                    m.JediVainqueur = null;
                    m.Jedi1         = null;
                    m.Jedi2         = null;
                    m.Phase         = ((EPhaseTournoiWS)i);
                    m.Stade         = stadeList.First(x => x.Id == Convert.ToInt32(collection.Get("stadefor" + i)));

                    tournoi.Matches.Add(m);
                }

                List <MatchWS> vraiMatches = new List <MatchWS>();
                foreach (var m in tournoi.Matches)
                {
                    service.addMatch(m);
                }
                List <MatchWS> mmm = service.getMatches();
                foreach (var m in tournoi.Matches)
                {
                    if (m.Phase >= EPhaseTournoiWS.HuitiemeFinale8)
                    {
                        vraiMatches.Add(mmm.Find(x => x.Phase == m.Phase &&
                                                 x.Jedi1.Nom == m.Jedi1.Nom &&
                                                 x.Jedi2.Nom == m.Jedi2.Nom &&
                                                 x.Stade.Planete == m.Stade.Planete));
                    }
                    else
                    {
                        vraiMatches.Add(mmm.Find(x => x.Stade.Planete == m.Stade.Planete &&
                                                 x.Phase == m.Phase));
                    }
                }
                tournoi.Matches = vraiMatches;
                service.addTournoi(tournoi);
            }

            return(RedirectToAction("Index"));
            //} catch {
            //	return View("Error");
            //}
        }
コード例 #5
0
        public ActionResult Create(FormCollection collection)
        {
            //try {
            ServiceReference.TournoiWS tournoi = new ServiceReference.TournoiWS();
            List<JediWS> jediList = new List<JediWS>();
            List<StadeWS> stadeList = new List<StadeWS>();

            using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient())
            {
                service.getJedis().ForEach(x => jediList.Add(x));
                service.getStades().ForEach(x => stadeList.Add(x));

                tournoi.Id = 0;
                tournoi.Nom = Convert.ToString(collection.Get("Item1.Nom"));
                tournoi.Matches = new List<MatchWS>();

                // Va chercher jedi1, jedi2 et stade pour les huitieme
                for (int i = (int)EPhaseTournoiWS.HuitiemeFinale1; i >= (int)EPhaseTournoiWS.HuitiemeFinale8; i--)
                {
                    MatchWS m = new MatchWS();
                    m.Id = 0;
                    m.JediVainqueur = null;
                    m.Phase = ((EPhaseTournoiWS)i);
                    m.Stade = stadeList.First(x => x.Id == Convert.ToInt32(collection.Get("stadefor" + i)));
                    m.Jedi1 = jediList.First(x => x.Id == Convert.ToInt32(collection.Get("jedi1for" + i)));
                    m.Jedi2 = jediList.First(x => x.Id == Convert.ToInt32(collection.Get("jedi2for" + i)));
                    tournoi.Matches.Add(m);
                    // TODO : ai-je besoin des participants ?
                }

                // Va chercher stade pour les autres phases
                for (int i = (int)EPhaseTournoiWS.QuartFinale1; i >= (int)EPhaseTournoiWS.Finale; i--)
                {
                    MatchWS m = new MatchWS();
                    m.Id = 0;
                    m.JediVainqueur = null;
                    m.Jedi1 = null;
                    m.Jedi2 = null;
                    m.Phase = ((EPhaseTournoiWS)i);
                    m.Stade = stadeList.First(x => x.Id == Convert.ToInt32(collection.Get("stadefor" + i)));

                    tournoi.Matches.Add(m);
                }

                List<MatchWS> vraiMatches = new List<MatchWS>();
                foreach (var m in tournoi.Matches)
                {
                    service.addMatch(m);
                }
                List<MatchWS> mmm = service.getMatches();
                foreach (var m in tournoi.Matches)
                {
                    if (m.Phase >= EPhaseTournoiWS.HuitiemeFinale8)
                    {
                        vraiMatches.Add(mmm.Find(x => x.Phase == m.Phase
                                                && x.Jedi1.Nom == m.Jedi1.Nom
                                                && x.Jedi2.Nom == m.Jedi2.Nom
                                                && x.Stade.Planete == m.Stade.Planete));
                    }
                    else
                    {
                        vraiMatches.Add(mmm.Find(x => x.Stade.Planete == m.Stade.Planete
                                                && x.Phase == m.Phase));
                    }
                }
                tournoi.Matches = vraiMatches;
                service.addTournoi(tournoi);
            }

            return RedirectToAction("Index");
            //} catch {
            //	return View("Error");
            //}
        }