예제 #1
0
        public ActionResult AssignPlayer(int id)
        {
            EventCountry EC = db.GetEventCountry(id);

            AssignPlayerVM model = new AssignPlayerVM
            {
                EventCountry = EC,
                Players      = new SelectList(db.GetPlayersForYear(EC.Event.Year), "PlayerGuid", "Name")
            };

            return(View(model));
        }
예제 #2
0
        public ActionResult Score(PlayerEventCountryScore model)
        {
            //check validity of user
            Guid currentplayer = (Guid)Membership.GetUser().ProviderUserKey;

            if (currentplayer != model.PlayerGuid)
            {
                //invalid user -- throw error
                throw new Exception("You are not the correct player for this record");
            }
            //check validity of model
            try
            {
                if (ModelState.IsValid)
                {
                    db.RecordPlayerScore(model);
                    return(RedirectToAction("Play"));
                }
                else
                {
                    throw new Exception("Modelstate.invalid");
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Error", ex);
                model.EventCountry = db.GetEventCountry(model.EventCountryID);
                return(View(model));
            }
        }