public ActionResult Create(FormCollection collection)
        {
            try
            {
                ServiceJediClient service = new ServiceJediClient();
                List<CaracteristiqueWCF> listCar = service.getAllCaracteristique().ToList();

                StadeWCF stadeWCf = new StadeWCF();
                stadeWCf.Planete = collection[1];
                stadeWCf.NbPlaces = Int32.Parse(collection[2]);

                List<CaracteristiqueWCF> listCarRes = new List<CaracteristiqueWCF>();
                char[] delimiterChars = { ',' };
                string[] caractStr = collection[3].Split(delimiterChars);
                foreach (string str in caractStr)
                {
                    if (str != "false")
                    {
                        listCarRes.Add(listCar.Find(x => x.Id == Int32.Parse(str)));
                    }
                }

                stadeWCf.Caracteristiques = listCarRes.ToArray();

                service.addStade(stadeWCf);
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                ServiceJediClient         service = new ServiceJediClient();
                List <CaracteristiqueWCF> listCar = service.getAllCaracteristique().ToList();

                JediWCF jediWCF = new JediWCF();
                jediWCF.Nom    = collection[1];
                jediWCF.IsSith = collection[2].StartsWith("true");

                List <CaracteristiqueWCF> listCarRes = new List <CaracteristiqueWCF>();
                char[]   delimiterChars = { ',' };
                string[] caractStr      = collection[3].Split(delimiterChars);
                foreach (string str in caractStr)
                {
                    if (str != "false")
                    {
                        listCarRes.Add(listCar.Find(x => x.Id == Int32.Parse(str)));
                    }
                }

                jediWCF.Caracteristiques = listCarRes.ToArray();

                service.addJedi(jediWCF);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                ServiceJediClient         service = new ServiceJediClient();
                List <CaracteristiqueWCF> listCar = service.getAllCaracteristique().ToList();

                StadeWCF stadeWCF = service.getAllStade().ToList().Find(x => x.Id == id);
                stadeWCF.Planete  = collection[2];
                stadeWCF.NbPlaces = Int32.Parse(collection[3]);

                List <CaracteristiqueWCF> listCarRes = new List <CaracteristiqueWCF>();
                char[]   delimiterChars = { ',' };
                string[] caractStr      = collection[4].Split(delimiterChars);
                foreach (string str in caractStr)
                {
                    if (str != "false")
                    {
                        listCarRes.Add(listCar.Find(x => x.Id == Int32.Parse(str)));
                    }
                }

                stadeWCF.Caracteristiques = listCarRes.ToArray();

                service.updateStade(stadeWCF);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult End(int idJedi, int bank, bool win)
        {
            ServiceJediClient service = new ServiceJediClient();

            TournoiEnd tournoiEnd = new TournoiEnd();
            string     str;

            if (win)
            {
                str = "Vous avez bien parie sur ce dernier match ! Felicitation ! ";
            }
            else
            {
                str = "Vous avez mal parie sur ce dernier match ";
            }

            JediModels jedi = new JediModels(service.getAllJedi().ToList().Find(x => x.Id == idJedi));

            tournoiEnd.Bank        = bank;
            tournoiEnd.JediGagnant = jedi.Nom;
            tournoiEnd.MessageEnd  = str;


            return(View(tournoiEnd));
        }
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                ServiceJediClient service = new ServiceJediClient();
                List<CaracteristiqueWCF> listCar = service.getAllCaracteristique().ToList();

                JediWCF jediWCF = new JediWCF();
                jediWCF.Nom = collection[1];
                jediWCF.IsSith = collection[2].StartsWith("true");

                List<CaracteristiqueWCF> listCarRes = new List<CaracteristiqueWCF>();
                char[] delimiterChars = {','};
                string[] caractStr = collection[3].Split(delimiterChars);
                foreach (string str in caractStr)
                {
                    if (str != "false")
                    {
                        listCarRes.Add(listCar.Find(x => x.Id == Int32.Parse(str)));
                    }
                }

                jediWCF.Caracteristiques = listCarRes.ToArray();

                service.addJedi(jediWCF);
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
 // GET: Stade/Delete/5
 public ActionResult Delete(int id)
 {
     ServiceJediClient service = new ServiceJediClient();
     StadeWCF stade = service.getAllStade().ToList().Find(x => x.Id == id);
     if (stade == null)
     {
         return HttpNotFound();
     }
     return View(new StadeModels(stade));
 }
 // GET: Tournoi/Delete/5
 public ActionResult Delete(int id)
 {
     ServiceJediClient service = new ServiceJediClient();
     TournoiWCF t = service.getAllTournoi().ToList().Find(x => x.Id == id);
     if (t == null)
     {
         return HttpNotFound();
     }
     return View(new TournoiModels(t));
 }
 //
 // GET: /Jedi/Delete/5
 public ActionResult Delete(int id)
 {
     ServiceJediClient service = new ServiceJediClient();
     JediWCF jedi = service.getAllJedi().ToList().Find(x => x.Id == id);
     if (jedi == null)
     {
         return HttpNotFound();
     }
     return View(new JediModels(jedi));
 }
 // GET: Match/Details/5
 public ActionResult Details(int id)
 {
     ServiceJediClient service = new ServiceJediClient();
     MatchWCF match = service.getAllMatch().ToList().Find(x => x.Id == id);
     if (match == null)
     {
         return HttpNotFound();
     }
     return View(new MatchModels(match));
 }
        // GET: Tournoi/Delete/5
        public ActionResult Delete(int id)
        {
            ServiceJediClient service = new ServiceJediClient();
            TournoiWCF        t       = service.getAllTournoi().ToList().Find(x => x.Id == id);

            if (t == null)
            {
                return(HttpNotFound());
            }
            return(View(new TournoiModels(t)));
        }
Beispiel #11
0
        // GET: Caracteristique/Edit/5
        public ActionResult Edit(int id)
        {
            ServiceJediClient  service = new ServiceJediClient();
            CaracteristiqueWCF cara    = service.getAllCaracteristique().ToList().Find(x => x.Id == id);

            if (cara == null)
            {
                return(HttpNotFound());
            }
            return(View(new CaracteristiqueModels(cara)));
        }
        public ActionResult ListJedi()
        {
            ServiceJediClient service = new ServiceJediClient();
            List <JediModels> list    = new List <JediModels>();

            foreach (JediWCF j in service.getAllJedi())
            {
                list.Add(new JediModels(j));
            }
            return(PartialView(list));
        }
Beispiel #13
0
        // GET: Match/Edit/5
        public ActionResult Edit(int id)
        {
            ServiceJediClient service = new ServiceJediClient();
            MatchWCF          match   = service.getAllMatch().ToList().Find(x => x.Id == id);

            if (match == null)
            {
                return(HttpNotFound());
            }
            return(View(new MatchModels(match)));
        }
        //
        // GET: /Jedi/Edit/5
        public ActionResult Edit(int id)
        {
            ServiceJediClient service = new ServiceJediClient();
            JediWCF           jedi    = service.getAllJedi().ToList().Find(x => x.Id == id);

            if (jedi == null)
            {
                return(HttpNotFound());
            }
            return(View(new JediModels(jedi)));
        }
        // GET: Stade/Edit/5
        public ActionResult Edit(int id)
        {
            ServiceJediClient service = new ServiceJediClient();
            StadeWCF          stade   = service.getAllStade().ToList().Find(x => x.Id == id);

            if (stade == null)
            {
                return(HttpNotFound());
            }
            return(View(new StadeModels(stade)));
        }
        public ActionResult ListStade()
        {
            ServiceJediClient  service = new ServiceJediClient();
            List <StadeModels> list    = new List <StadeModels>();

            foreach (StadeWCF s in service.getAllStade())
            {
                list.Add(new StadeModels(s));
            }
            return(PartialView(list));
        }
        // GET: Tournoi
        public ActionResult Index()
        {
            ServiceJediClient    service = new ServiceJediClient();
            List <TournoiModels> list    = new List <TournoiModels>();

            foreach (TournoiWCF t in service.getAllTournoi())
            {
                list.Add(new TournoiModels(t));
            }

            return(View(list));
        }
        // GET: Stade
        public ActionResult Index()
        {
            ServiceJediClient  service = new ServiceJediClient();
            List <StadeModels> list    = new List <StadeModels>();

            foreach (StadeWCF stade in service.getAllStade())
            {
                list.Add(new StadeModels(stade));
            }

            return(View(list));
        }
        //
        // GET: /Jedi/
        public ActionResult Index()
        {
            ServiceJediClient service = new ServiceJediClient();
            List <JediModels> list    = new List <JediModels>();

            foreach (JediWCF jedi in service.getAllJedi())
            {
                list.Add(new JediModels(jedi));
            }

            return(View(list));
        }
Beispiel #20
0
        // GET: Match
        public ActionResult Index()
        {
            ServiceJediClient  service = new ServiceJediClient();
            List <MatchModels> list    = new List <MatchModels>();

            foreach (MatchWCF match in service.getAllMatch())
            {
                list.Add(new MatchModels(match));
            }

            return(View(list));
        }
Beispiel #21
0
        // GET: Caracteristique
        public ActionResult Index()
        {
            ServiceJediClient            service = new ServiceJediClient();
            List <CaracteristiqueModels> list    = new List <CaracteristiqueModels>();

            foreach (CaracteristiqueWCF cara in service.getAllCaracteristique())
            {
                list.Add(new CaracteristiqueModels(cara));
            }

            return(View(list));
        }
 // GET: Tournoi/Details/5
 public ActionResult Details(int id, int bank)
 {
     ServiceJediClient service = new ServiceJediClient();
     TournoiWCF t = service.getAllTournoi().ToList().Find(x => x.Id == id);
     if (t == null)
     {
         return HttpNotFound();
     }
     TournoiModels tModels = new TournoiModels(t);
     tModels.bank = bank;
     return View(tModels);
 }
        // GET: Tournoi/Details/5
        public ActionResult Details(int id, int bank)
        {
            ServiceJediClient service = new ServiceJediClient();
            TournoiWCF        t       = service.getAllTournoi().ToList().Find(x => x.Id == id);

            if (t == null)
            {
                return(HttpNotFound());
            }
            TournoiModels tModels = new TournoiModels(t);

            tModels.bank = bank;
            return(View(tModels));
        }
Beispiel #24
0
        public ActionResult ListCaracteristiqueStade()
        {
            ServiceJediClient            service = new ServiceJediClient();
            List <CaracteristiqueModels> list    = new List <CaracteristiqueModels>();

            foreach (CaracteristiqueWCF c in service.getAllCaracteristique())
            {
                if (c.Type == ETypeCaracteristique.Stade)
                {
                    list.Add(new CaracteristiqueModels(c));
                }
            }
            return(PartialView(list));
        }
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         ServiceJediClient service = new ServiceJediClient();
         JediWCF           jedi    = service.getAllJedi().ToList().Find(x => x.Id == id);
         if (jedi == null)
         {
             return(HttpNotFound());
         }
         service.deleteJedi(jedi);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         ServiceJediClient service = new ServiceJediClient();
         JediWCF jedi = service.getAllJedi().ToList().Find(x => x.Id == id);
         if (jedi == null)
         {
             return HttpNotFound();
         }
         service.deleteJedi(jedi);
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Beispiel #27
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         ServiceJediClient  service = new ServiceJediClient();
         CaracteristiqueWCF cara    = service.getAllCaracteristique().ToList().Find(x => x.Id == id);
         if (cara == null)
         {
             return(HttpNotFound());
         }
         service.deleteCaracteristique(cara);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public ActionResult ListJediConcourant(int id)
        {
            ServiceJediClient service = new ServiceJediClient();
            List <JediModels> list    = new List <JediModels>();

            TournoiWCF t = service.getAllTournoi().ToList().Find(x => x.Id == id);

            foreach (MatchWCF m in t.Matches)
            {
                list.Add(new JediModels(m.Jedi1));
                list.Add(new JediModels(m.Jedi2));
            }
            list.Sort(delegate(JediModels x, JediModels y)
            {
                return(x.Nom.CompareTo(y.Nom));
            });
            return(PartialView(list));
        }
Beispiel #29
0
        public ActionResult Create(int Def, string Nom, int Type, int Valeur)
        {
            try
            {
                ServiceJediClient  service = new ServiceJediClient();
                CaracteristiqueWCF c       = new CaracteristiqueWCF();
                c.Definition = (EDefCaracteristique)Def;
                c.Nom        = Nom;
                c.Type       = (ETypeCaracteristique)Type;
                c.Valeur     = Valeur;

                service.addCracteristique(c);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #30
0
        public ActionResult Edit(int id, int Def, string Nom, int Type, int Valeur)
        {
            try
            {
                ServiceJediClient service = new ServiceJediClient();

                CaracteristiqueWCF c = service.getAllCaracteristique().ToList().Find(x => x.Id == id);
                c.Definition = (EDefCaracteristique)Def;
                c.Nom        = Nom;
                c.Type       = (ETypeCaracteristique)Type;
                c.Valeur     = Valeur;

                service.updateCaracteristique(c);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #31
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                ServiceJediClient service    = new ServiceJediClient();
                List <JediWCF>    listJedis  = service.getAllJedi().ToList();
                List <StadeWCF>   listStades = service.getAllStade().ToList();
                MatchWCF          match      = service.getAllMatch().ToList().Find(x => x.Id == id);
                match.Jedi1        = listJedis.Find(x => x.Id == Int32.Parse(collection[2]));
                match.Jedi2        = listJedis.Find(x => x.Id == Int32.Parse(collection[3]));
                match.PhaseTournoi = (EPhaseTournoi)Enum.Parse(typeof(EPhaseTournoi), collection[4], true);
                match.Stade        = listStades.Find(x => x.Id == Int32.Parse(collection[5]));

                service.updateMatch(match);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Details(int id, int bank, int bet, int jediBet)
        {
            ServiceJediClient service = new ServiceJediClient();
            TournoiWCF        t       = service.getAllTournoi().ToList().Find(x => x.Id == id);

            bank -= bet;
            if (t == null)
            {
                return(HttpNotFound());
            }
            if (t.Matches.ToList().Count == 1)
            {
                return(RedirectToAction("End", new { bank = bank, win = true, idJedi = t.Matches[0].Jedi1.Id }));
            }
            else
            {
                // Jouer les matches et recuperer le nouveau tournois
                TournoiWCF tnew = service.playTournoi(t);
                string     nom  = t.Nom + " " + tnew.Matches[0].PhaseTournoi;
                tnew.Nom = nom;
                service.addTournoi(tnew);
                tnew = service.getAllTournoi().ToList().Find(x => x.Nom == nom);

                // Determine si le joueur a gagne
                bool win = false;
                for (int i = 0; i < tnew.Matches.ToList().Count&& !win; i++)
                {
                    if (tnew.Matches[i].Jedi1.Id == jediBet ||
                        tnew.Matches[i].Jedi2.Id == jediBet)
                    {
                        win   = true;
                        bank += bet * 2;
                    }
                }

                return(RedirectToAction("Details", new { Id = tnew.Id, bank = bank }));
            }
        }
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                string str1 = collection[0];
                string str2 = collection[1];

                ServiceJediClient service = new ServiceJediClient();
                List<JediWCF> listJedis = service.getAllJedi().ToList();
                List<StadeWCF> listStades = service.getAllStade().ToList();
                MatchWCF match = new MatchWCF();
                match.Jedi1 = listJedis.Find(x => x.Id == Int32.Parse(collection[1]));
                match.Jedi2 = listJedis.Find(x => x .Id == Int32.Parse(collection[2]));
                match.PhaseTournoi = (EPhaseTournoi)Enum.Parse(typeof(EPhaseTournoi), collection[3], true);
                match.Stade = listStades.Find(x => x.Id == Int32.Parse(collection[4]));

                service.addMatch(match);
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Beispiel #34
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                string str1 = collection[0];
                string str2 = collection[1];

                ServiceJediClient service    = new ServiceJediClient();
                List <JediWCF>    listJedis  = service.getAllJedi().ToList();
                List <StadeWCF>   listStades = service.getAllStade().ToList();
                MatchWCF          match      = new MatchWCF();
                match.Jedi1        = listJedis.Find(x => x.Id == Int32.Parse(collection[1]));
                match.Jedi2        = listJedis.Find(x => x.Id == Int32.Parse(collection[2]));
                match.PhaseTournoi = (EPhaseTournoi)Enum.Parse(typeof(EPhaseTournoi), collection[3], true);
                match.Stade        = listStades.Find(x => x.Id == Int32.Parse(collection[4]));

                service.addMatch(match);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
 public ActionResult ListStade()
 {
     ServiceJediClient service = new ServiceJediClient();
     List<StadeModels> list = new List<StadeModels>();
     foreach (StadeWCF s in service.getAllStade())
     {
         list.Add(new StadeModels(s));
     }
     return PartialView(list);
 }
        // GET: Stade
        public ActionResult Index()
        {
            ServiceJediClient service = new ServiceJediClient();
            List<StadeModels> list = new List<StadeModels>();

            foreach (StadeWCF stade in service.getAllStade())
            {
                list.Add(new StadeModels(stade));
            }

            return View(list);
        }
        // GET: Match
        public ActionResult Index()
        {
            ServiceJediClient service = new ServiceJediClient();
            List<MatchModels> list = new List<MatchModels>();

            foreach (MatchWCF match in service.getAllMatch())
            {
                list.Add(new MatchModels(match));
            }

            return View(list);
        }
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                ServiceJediClient service = new ServiceJediClient();
                List<JediWCF> listJedis = service.getAllJedi().ToList();
                List<StadeWCF> listStades = service.getAllStade().ToList();
                MatchWCF match = service.getAllMatch().ToList().Find(x => x.Id == id);
                match.Jedi1 = listJedis.Find(x => x.Id == Int32.Parse(collection[2]));
                match.Jedi2 = listJedis.Find(x => x.Id == Int32.Parse(collection[3]));
                match.PhaseTournoi = (EPhaseTournoi)Enum.Parse(typeof(EPhaseTournoi), collection[4], true);
                match.Stade = listStades.Find(x => x.Id == Int32.Parse(collection[5]));

                service.updateMatch(match);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        // GET: Tournoi
        public ActionResult Index()
        {
            ServiceJediClient service = new ServiceJediClient();
            List<TournoiModels> list = new List<TournoiModels>();

            foreach (TournoiWCF t in service.getAllTournoi())
            {
                list.Add(new TournoiModels(t));
            }

            return View(list);
        }
 public ActionResult ListJedi()
 {
     ServiceJediClient service = new ServiceJediClient();
     List<JediModels> list = new List<JediModels>();
     foreach (JediWCF j in service.getAllJedi())
     {
         list.Add(new JediModels(j));
     }
     return PartialView(list);
 }
        //
        // GET: /Jedi/
        public ActionResult Index()
        {
            ServiceJediClient service = new ServiceJediClient();
            List<JediModels> list = new List<JediModels>();

            foreach (JediWCF jedi in service.getAllJedi())
            {
                list.Add(new JediModels(jedi));
            }

            return View(list);
        }
        public ActionResult ListJediConcourant(int id)
        {
            ServiceJediClient service = new ServiceJediClient();
            List<JediModels> list = new List<JediModels>();

            TournoiWCF t = service.getAllTournoi().ToList().Find(x => x.Id == id);

            foreach (MatchWCF m in t.Matches)
            {
                list.Add(new JediModels(m.Jedi1));
                list.Add(new JediModels(m.Jedi2));
            }
            list.Sort(delegate (JediModels x, JediModels y)
            {
                return x.Nom.CompareTo(y.Nom);
            });
            return PartialView(list);
        }
        public ActionResult Details(int id, int bank, int bet, int jediBet)
        {
            ServiceJediClient service = new ServiceJediClient();
            TournoiWCF t = service.getAllTournoi().ToList().Find(x => x.Id == id);
            bank -= bet;
            if (t == null)
            {
                return HttpNotFound();
            }
            if (t.Matches.ToList().Count == 1)
            {
                return RedirectToAction("End",new { bank = bank, win = true, idJedi = t.Matches[0].Jedi1.Id });
            }
            else
            {
                // Jouer les matches et recuperer le nouveau tournois
                TournoiWCF tnew = service.playTournoi(t);
                string nom = t.Nom + " " + tnew.Matches[0].PhaseTournoi;
                tnew.Nom = nom;
                service.addTournoi(tnew);
                tnew = service.getAllTournoi().ToList().Find(x => x.Nom == nom);

                // Determine si le joueur a gagne
                bool win = false;
                for(int i=0; i<tnew.Matches.ToList().Count && !win; i++)
                {
                    if(tnew.Matches[i].Jedi1.Id == jediBet ||
                        tnew.Matches[i].Jedi2.Id == jediBet)
                    {
                        win = true;
                        bank += bet * 2;
                    }
                }

                return RedirectToAction("Details", new { Id = tnew.Id, bank = bank });
            }
        }
        public ActionResult End(int idJedi, int bank, bool win)
        {
            ServiceJediClient service = new ServiceJediClient();

            TournoiEnd tournoiEnd = new TournoiEnd();
            string str;
            if (win)
            {
                str = "Vous avez bien parie sur ce dernier match ! Felicitation ! ";
            }
            else
            {
                str = "Vous avez mal parie sur ce dernier match ";
            }

            JediModels jedi = new JediModels(service.getAllJedi().ToList().Find(x => x.Id == idJedi));

            tournoiEnd.Bank = bank;
            tournoiEnd.JediGagnant = jedi.Nom;
            tournoiEnd.MessageEnd = str;

            return View(tournoiEnd);
        }