コード例 #1
0
        public void deleteTournois(TournoiWCF tournoi)
        {
            List <Tournoi> tournois        = bm.getTournoi();
            int            index_to_modify = tournois.FindIndex(x => x.Id == tournoi.Id);

            tournois.RemoveAt(index_to_modify);
            bm.updateTournoi(tournois);
        }
コード例 #2
0
        public void updateTournois(TournoiWCF tournoi)
        {
            List <Tournoi> tournois        = bm.getTournoi();
            int            index_to_modify = tournois.FindIndex(x => x.Id == tournoi.Id);

            tournois[index_to_modify] = tournoi.toTournoi();
            bm.updateTournoi(tournois);
        }
コード例 #3
0
        // 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)));
        }
コード例 #4
0
        public void addTournoi(TournoiWCF tournoi)
        {
            List <Tournoi> tournois  = bm.getTournoi();
            List <Match>   listMatch = new List <Match>();

            foreach (MatchWCF match in tournoi.Matches)
            {
                listMatch.Add(match.toMatch());
            }
            tournois.Add(new Tournoi(listMatch, tournoi.Nom));
            bm.updateTournoi(tournois);
        }
コード例 #5
0
 public TournoiModels(TournoiWCF tournoi)
 {
     TournoiWCF = tournoi;
     Id = tournoi.Id;
     Nom = tournoi.Nom;
     bank = 500;
     List<MatchModels> list = new List<MatchModels>();
     foreach(MatchWCF m in tournoi.Matches)
     {
         list.Add(new MatchModels(m));
     }
     Matches = new MatchCollection(list);
 }
コード例 #6
0
        public TournoiModels(TournoiWCF tournoi)
        {
            TournoiWCF = tournoi;
            Id         = tournoi.Id;
            Nom        = tournoi.Nom;
            bank       = 500;
            List <MatchModels> list = new List <MatchModels>();

            foreach (MatchWCF m in tournoi.Matches)
            {
                list.Add(new MatchModels(m));
            }
            Matches = new MatchCollection(list);
        }
コード例 #7
0
        // 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));
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                ServiceJediClient service = new ServiceJediClient();
                TournoiWCF        t       = service.getAllTournoi().ToList().Find(x => x.Id == id);
                if (t == null)
                {
                    return(HttpNotFound());
                }
                service.deleteTournois(t);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #10
0
        public void TournoiTest()
        {
            //get
            ServiceJediReference.ServiceJediClient service = new ServiceJediReference.ServiceJediClient();
            List <TournoiWCF> result = service.getAllTournoi();

            BusinessLayer.BusinessManager bm = new BusinessLayer.BusinessManager();
            List <Tournoi>    original       = bm.getTournoi();
            List <TournoiWCF> expected       = new List <TournoiWCF>();

            foreach (Tournoi tournois in original)
            {
                expected.Add(new TournoiWCF(tournois));
            }
            foreach (TournoiWCF tournois in expected)
            {
                Assert.IsTrue(result.Exists(x => x.Nom == tournois.Nom), "Le tournoi " + tournois.Nom + " n'est pas present");
            }

            //add
            List <Match> matches = bm.getMatches();
            TournoiWCF   t       = new TournoiWCF(new Tournoi(matches, "Tournoistest"));

            service.addTournoi(t);
            result = service.getAllTournoi();
            Assert.IsTrue(result.Exists(x => x.Nom == t.Nom), "Le tournois " + t.Nom + " n'est pas present");

            //update
            t     = result.Find(x => x.Nom == "Tournoistest");
            t.Nom = "Tournoistest2";
            service.updateTournois(t);
            result = service.getAllTournoi();
            Assert.IsTrue(result.Exists(x => x.Nom == "Tournoistest2"), "Le tournois " + t.Nom + " n'a pas ete modife");

            //delete
            service.deleteTournois(t);
            result = service.getAllTournoi();
            Assert.IsTrue(!result.Exists(x => x.Nom == "Tournoistest2"), "Le tournois " + t.Nom + "existe toujours");
        }
コード例 #11
0
        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 }));
            }
        }
コード例 #12
0
 public TournoiWebModel(TournoiWCF t)
 {
     this.Id = t.Id;
     this.Nom = t.Nom;
 }
コード例 #13
0
 public TournoiWebModel(TournoiWCF t)
 {
     this.Id  = t.Id;
     this.Nom = t.Nom;
 }
コード例 #14
0
 public TournoiWCF playTournoi(TournoiWCF tournoi)
 {
     return(new TournoiWCF(bm.playTournoi(tournoi.toTournoi())));
 }