Esempio n. 1
0
        public ActionResult Index(FormCollection collection)
        {
            TournoiWS ts = null;
            string nom = collection.Get(1);
            using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient())
            {
                TournoiWS tn = service.getTournois().Where(x => x.Nom == nom).First();
                ts = service.playTournoi(tn);
            }
            TournoiViewModel mod = new TournoiViewModel(ts);

            using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient())
            {
                int butin = service.getPoints(User.Identity.GetUserName());
                mod.Mise = Int32.Parse(collection.Get("Mise"));
                mod.Mise = (mod.Mise < 0 ? 0 : mod.Mise > butin ? butin : mod.Mise);
                mod.Jedi = collection.Get("Jedi");
                bool gagne = mod.Jedi == mod.Matches.list.Where(x => x.Phase == EPhaseTournoiWS.Finale).First().JediVainqueur.Nom;
                mod.Gain = (gagne ? mod.Mise * 2 + 1 : 0);
                var userId = User.Identity.GetUserId();

                mod.Total = service.getPoints(User.Identity.GetUserName());
                mod.Total += (gagne ? mod.Gain : -mod.Mise);
                mod.Total = mod.Total < 0 ? 0 : mod.Total;
                service.setPoints(User.Identity.GetUserName(), mod.Total);
            }

            return View("Details", mod);
        }
Esempio n. 2
0
 public ActionResult Details(TournoiViewModel tws)
 {
     return View(tws);
 }