public ActionResult Create(RegisterCard registerCard)
        {
            Competition competition;

            if (ModelState.IsValid)
            {
                // Shoots will be null from mobile form
                if (registerCard.Shoots == null)
                {
                    competition = _db.Competitions.Find(registerCard.IndividualCompetitionId);
                    registerCard.InitialiseShoots(
                        competition.Distances.ToList(),
                        competition.NumberOfSightingShots,
                        competition.NumberOfScoringShots
                        );
                }

                _db.RegisterCards.Add(registerCard);
                _db.SaveChanges();
                RegisterKeeperHub.BroadcastNewRegisterCardToClients(registerCard.Id);

                return(Request.Browser.IsMobileDevice || HttpContext.GetOverriddenBrowser().IsMobileDevice ?
                       RedirectToAction("Details", "RegisterCards", new { id = registerCard.Id }) :
                       RedirectToAction("Details", "IndividualCompetitions", new { id = registerCard.IndividualCompetitionId }));
            }

            competition = _db.Competitions.Find(registerCard.IndividualCompetitionId);
            AddCompetitionDetailsToViewBag(competition, ViewBag);

            return(View(registerCard));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            var registerCard = _db.RegisterCards.Find(id);

            registerCard.CascadeDeleteShoots(_db);
            _db.RegisterCards.Remove(registerCard);
            _db.SaveChanges();
            RegisterKeeperHub.BroadcastDeletedRegisterCardToClients(registerCard.Id);
            return(RedirectToAction("Details", "IndividualCompetitions", new { id = registerCard.IndividualCompetitionId }));
        }
예제 #3
0
        public ActionResult ConvertSecondOrOnly(int shootId)
        {
            var shoot = _db.Shoots.Find(shootId);

            shoot.FirstToCount.Score     = shoot.FinalSighter.Score;
            shoot.FinalSighter.Converted = true;

            _db.SaveChanges();

            RegisterKeeperHub.BroadcastSighterConversionUpdateToClients(shoot.FinalSighter);
            RegisterKeeperHub.BroadcastScoreUpdateToClients(shoot.FirstToCount);

            // build view model for second to count
            var viewModel = BuildViewModel(shoot.ScoringShots.Single(s => s.ShotNumber == 2).Id);

            return(View("Scorer", viewModel));
        }
예제 #4
0
        public ActionResult ConvertBoth(int shootId)
        {
            var shoot = _db.Shoots.Find(shootId);

            // set first to count as value of first sighter
            shoot.FirstToCount.Score     = shoot.FirstSighter.Score;
            shoot.FirstSighter.Converted = true;

            // set second to count as value of second sighter
            shoot.SecondToCount.Score     = shoot.SecondSighter.Score;
            shoot.SecondSighter.Converted = true;

            _db.SaveChanges();

            RegisterKeeperHub.BroadcastSighterConversionUpdateToClients(shoot.FirstSighter);
            RegisterKeeperHub.BroadcastSighterConversionUpdateToClients(shoot.SecondSighter);
            RegisterKeeperHub.BroadcastScoreUpdateToClients(shoot.FirstToCount);
            RegisterKeeperHub.BroadcastScoreUpdateToClients(shoot.SecondToCount);

            // build view model for third to count
            var viewModel = BuildViewModel(shoot.ScoringShots.Single(s => s.ShotNumber == 3).Id);

            return(View("Scorer", viewModel));
        }