Esempio n. 1
0
 public ActionResult Join(EventPlayer model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             model.Event = db.GetEventByYear(model.Year);
             db.AddEventPlayer(model);
             HttpContext.Profile.SetPropertyValue("CurrentGame", model.Year);
             var CountryList = db.GetEventCountriesByYear(model.Year);
             ICollection <PlayerEventCountryScore> PECS = new List <PlayerEventCountryScore>();
             foreach (var item in CountryList)
             {
                 PECS.Add(new PlayerEventCountryScore
                 {
                     EventCountryID = item.CountryID,
                     PlayerGuid     = model.PlayerGuid,
                     EventCountry   = item
                 });
             }
             db.StartGameForPlayer(PECS);
             return(RedirectToAction("Play", "Game"));
         }
         else
         {
             throw new Exception("Modelstate invalid");
         }
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("Error", ex.InnerException);
         return(View(model));
     }
 }