Esempio n. 1
0
 public void TestServiceGetStades()
 {
     ServiceReference.ServiceClient client = new ServiceReference.ServiceClient();
     List<StadeWS> stades = client.getStades();
     Assert.IsNotNull(stades);
     StadeWS kamino = stades.Find(x => x.Planete.Equals("Kamino"));
     Assert.AreEqual(2, kamino.Caracteristiques.Count);
     Assert.IsNotNull(kamino);
     client.Close();
 }
Esempio n. 2
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                ServiceReference.TournoiWS tournoi = null;
                List <JediWS>  jediList            = new List <JediWS>();
                List <StadeWS> stadeList           = new List <StadeWS>();

                using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient())
                {
                    tournoi = service.getTournois().First(x => x.Id == id);

                    if (tournoi == null)
                    {
                        return(HttpNotFound());
                    }

                    service.getJedis().ForEach(x => jediList.Add(x));
                    service.getStades().ForEach(x => stadeList.Add(x));

                    tournoi.Nom = Convert.ToString(collection.Get("Item1.Nom"));

                    // Mise a jour des matchs
                    foreach (var m in tournoi.Matches)
                    {
                        int i = ((int)m.Phase);
                        if (m.Phase >= EPhaseTournoiWS.HuitiemeFinale8 && m.Phase <= EPhaseTournoiWS.HuitiemeFinale1)
                        { // Mise a jour jedis
                            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)));
                        }
                        else
                        {
                            m.Jedi1 = null;
                            m.Jedi2 = null;
                        }
                        m.JediVainqueur = null;
                        m.Stade         = stadeList.First(x => x.Id == Convert.ToInt32(collection.Get("stadefor" + i)));
                    }

                    foreach (var m in tournoi.Matches)
                    {
                        service.updateMatch(m);
                    }
                    service.updateTournoi(tournoi);
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(RedirectToAction("Error"));
            }
        }
Esempio n. 3
0
		// GET: Stade
		public ActionResult Index() {
			List<StadeViewModel> list = new List<StadeViewModel>();

			using(ServiceReference.ServiceClient service = new ServiceReference.ServiceClient()) {
                foreach (var stade in service.getStades())
                {
                    list.Add(new StadeViewModel(stade));
                }
            }

			return View(new StadeCollection(list));
		}
Esempio n. 4
0
        // GET: Tournoi/Create
        public ActionResult Create()
        {
            List<JediViewModel> jediList = new List<JediViewModel>();
            List<StadeViewModel> stadeListe = new List<StadeViewModel>();

            using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient())
            {
                service.getJedis().ForEach(x => jediList.Add(new JediViewModel(x)));
                service.getStades().ForEach(x => stadeListe.Add(new StadeViewModel(x)));
            }

            return View(Tuple.Create(new TournoiViewModel(), new JediCollection(jediList), new StadeCollection(stadeListe)));
        }
Esempio n. 5
0
        // GET: Stade
        public ActionResult Index()
        {
            List <StadeViewModel> list = new List <StadeViewModel>();

            using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient()) {
                foreach (var stade in service.getStades())
                {
                    list.Add(new StadeViewModel(stade));
                }
            }

            return(View(new StadeCollection(list)));
        }
Esempio n. 6
0
        // GET: Tournoi/Create
        public ActionResult Create()
        {
            List <JediViewModel>  jediList   = new List <JediViewModel>();
            List <StadeViewModel> stadeListe = new List <StadeViewModel>();

            using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient())
            {
                service.getJedis().ForEach(x => jediList.Add(new JediViewModel(x)));
                service.getStades().ForEach(x => stadeListe.Add(new StadeViewModel(x)));
            }

            return(View(Tuple.Create(new TournoiViewModel(), new JediCollection(jediList), new StadeCollection(stadeListe))));
        }
Esempio n. 7
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try {
                WebApplicationJedi.ServiceReference.StadeWS stade = null;
                using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient()) {
                    stade = service.getStades().First(x => x.Id == id);

                    if (stade != null)
                    {
                        service.removeStade(stade);
                    }
                }

                return(RedirectToAction("Index"));
            } catch {
                return(RedirectToAction("Index"));
            }
        }
Esempio n. 8
0
        // GET: Stade/Delete/5
        public ActionResult Delete(int id)
        {
            try {
                WebApplicationJedi.ServiceReference.StadeWS stade = null;

                using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient()) {
                    stade = service.getStades().First(x => x.Id == id);
                }

                if (stade == null)
                {
                    return(RedirectToAction("Index"));
                }

                return(View(new StadeViewModel(stade)));
            } catch {
                return(RedirectToAction("Index"));
            }
        }
Esempio n. 9
0
        // GET: Tournoi/Edit/5
        public ActionResult Edit(int id)
        {
            ServiceReference.TournoiWS tournoi   = null;
            List <JediViewModel>       jediList  = new List <JediViewModel>();
            List <StadeViewModel>      stadeList = new List <StadeViewModel>();

            using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient())
            {
                tournoi = service.getTournois().First(x => x.Id == id);

                if (tournoi == null)
                {
                    return(HttpNotFound());
                }

                service.getJedis().ForEach(x => jediList.Add(new JediViewModel(x)));
                service.getStades().ForEach(x => stadeList.Add(new StadeViewModel(x)));
            }

            return(View(Tuple.Create(new TournoiViewModel(tournoi), new JediCollection(jediList), new StadeCollection(stadeList))));
        }
Esempio n. 10
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");
            //}
        }
Esempio n. 11
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                ServiceReference.TournoiWS tournoi = null;
                List<JediWS> jediList = new List<JediWS>();
                List<StadeWS> stadeList = new List<StadeWS>();

                using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient())
                {
                    tournoi = service.getTournois().First(x => x.Id == id);

                    if (tournoi == null)
                    {
                        return HttpNotFound();
                    }

                    service.getJedis().ForEach(x => jediList.Add(x));
                    service.getStades().ForEach(x => stadeList.Add(x));

                    tournoi.Nom = Convert.ToString(collection.Get("Item1.Nom"));

                    // Mise a jour des matchs
                    foreach (var m in tournoi.Matches)
                    {
                        int i = ((int)m.Phase);
                        if (m.Phase >= EPhaseTournoiWS.HuitiemeFinale8 && m.Phase <= EPhaseTournoiWS.HuitiemeFinale1)
                        { // Mise a jour jedis
                            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)));
                        }
                        else {
                            m.Jedi1 = null;
                            m.Jedi2 = null;
                        }
                        m.JediVainqueur = null;
                        m.Stade = stadeList.First(x => x.Id == Convert.ToInt32(collection.Get("stadefor" + i)));
                    }

                    foreach (var m in tournoi.Matches)
                    {
                        service.updateMatch(m);
                    }
                    service.updateTournoi(tournoi);
                }

                return RedirectToAction("Index");
            }
            catch
            {
                return RedirectToAction("Error");
            }
        }
Esempio n. 12
0
        // GET: Tournoi/Edit/5
        public ActionResult Edit(int id)
        {
            ServiceReference.TournoiWS tournoi = null;
            List<JediViewModel> jediList = new List<JediViewModel>();
            List<StadeViewModel> stadeList = new List<StadeViewModel>();

            using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient())
            {
                tournoi = service.getTournois().First(x => x.Id == id);

                if (tournoi == null)
                {
                    return HttpNotFound();
                }

                service.getJedis().ForEach(x => jediList.Add(new JediViewModel(x)));
                service.getStades().ForEach(x => stadeList.Add(new StadeViewModel(x)));
            }

            return View(Tuple.Create(new TournoiViewModel(tournoi), new JediCollection(jediList), new StadeCollection(stadeList)));
        }
Esempio n. 13
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();
        }
Esempio n. 14
0
		public ActionResult Delete(int id, FormCollection collection) {
			try {
				WebApplicationJedi.ServiceReference.StadeWS stade = null;
				using(ServiceReference.ServiceClient service = new ServiceReference.ServiceClient()) {
					stade = service.getStades().First(x => x.Id == id);

					if(stade != null) {
						service.removeStade(stade);
					}
				}

				return RedirectToAction("Index");
			} catch {
				return RedirectToAction("Index");
			}
		}
Esempio n. 15
0
		// GET: Stade/Delete/5
		public ActionResult Delete(int id) {
			try {
				WebApplicationJedi.ServiceReference.StadeWS stade = null;

				using(ServiceReference.ServiceClient service = new ServiceReference.ServiceClient()) {
					stade = service.getStades().First(x => x.Id == id);
				}

				if(stade == null) {
					return RedirectToAction("Index");
				}

				return View(new StadeViewModel(stade));

			} catch {
				return RedirectToAction("Index");
			}
		}
Esempio n. 16
0
        public void TestServiceUpdateStades()
        {
            ServiceReference.ServiceClient client = new ServiceReference.ServiceClient();

            List<StadeWS> stades = client.getStades();
            Assert.IsNotNull(stades);
            StadeWS kamino = client.getStades().Find(x => x.Planete.Equals("Kamino"));
            kamino.NbPlaces = 10;
            client.updateStade(kamino);
            Assert.AreEqual(10, ((StadeWS)client.getStades().Find(x => x.Planete.Equals("Kamino"))).NbPlaces);
            kamino.NbPlaces = 100000;
            client.updateStade(kamino);
            Assert.AreEqual(100000, ((StadeWS)client.getStades().Find(x => x.Planete.Equals("Kamino"))).NbPlaces);

            client.Close();
        }
Esempio n. 17
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");
            //}
        }
Esempio n. 18
0
        public void TestServiceARStades()
        {
            ServiceReference.ServiceClient client = new ServiceReference.ServiceClient();

            List<StadeWS> stades = client.getStades();
            int size = stades.Count;
            Assert.IsNotNull(stades);
            /* AJOUT */
            StadeWS zone = new StadeWS(0, "Zone TEST", 11, new List<CaracteristiqueWS>());

            client.addStade(zone);
            Assert.AreEqual(size + 1, client.getStades().Count);
            /* SUPPRESSION */
            zone = client.getStades().Find(x => x.Planete.Equals("Zone TEST"));
            client.removeStade(zone);
            Assert.AreEqual(size, client.getStades().Count);

            client.Close();
        }