public ActionResult Create(CreatePlayerViewModel vm)
        {
            if (!ModelState.IsValid) return View(vm);

            var player = new Player(vm.Name, vm.Email, vm.Status);
            DocumentSession.Store(player);
            return RedirectToAction("Index");
        }
Exemple #2
0
        public void AddResultForPlayer(Player player, int score, int pins)
        {
            if (PlayerScores.ContainsKey(player.Id) == false)
            {
                PlayerScores.Add(player.Id, new PlayerScore(player.Id, player.Name, Team, TeamLevel));
            }

            var playerScore = PlayerScores[player.Id];
            playerScore.Score += score;
            playerScore.Pins += pins;
            playerScore.Series++;
        }
        public PlayerViewModel(Player player)
        {
            Id = player.Id;
            Name = player.Name;
            Email = player.Email;
            Status = player.PlayerStatus;
            switch (player.PlayerStatus)
            {
                case Player.Status.Active:
                    StatusText = "Aktiv";
                    break;

                case Player.Status.Inactive:
                    StatusText = "Inaktiv";
                    break;

                case Player.Status.Supporter:
                    StatusText = "Supporter";
                    break;
            }
        }
        public TeamOfWeekLeadersViewModelTest()
        {
            // Arrange
            var player1 = new Player("Daniel", "*****@*****.**", Player.Status.Active) { Id = "9876" };
            var player2 = new Player("Tomas", "*****@*****.**", Player.Status.Active) { Id = "8765" };
            var teamOfWeek1 = new TeamOfWeek(1234, 2012, 10, "Team A", "A");
            teamOfWeek1.AddResultForPlayer(player1, 1, 210);
            teamOfWeek1.AddResultForPlayer(player2, 1, 190);
            var teamOfWeek2 = new TeamOfWeek(5432, 2012, 10, "Team B", "B");
            teamOfWeek2.AddResultForPlayer(player1, 0, 220);
            teamOfWeek2.AddResultForPlayer(player2, 1, 180);

            // Act
            viewModel = new TeamOfWeekViewModel(
                2012,
                new[]
                {
                    teamOfWeek1,
                    teamOfWeek2
                });
        }
 private ActionResult Parse(
     RegisterBitsVerifyModel model,
     BitsParser parser,
     string content,
     Roster roster,
     Player[] players)
 {
     var result = parser.Parse(content, roster.Team);
     var vm = new RegisterBitsResult
     {
         BitsMatchId = roster.BitsMatchId,
         TeamScore = result.TeamScore,
         OpponentScore = result.OpponentScore,
         RosterId = model.RosterId,
         Serie1 = result.Series.ElementAtOrDefault(0),
         Serie2 = result.Series.ElementAtOrDefault(1),
         Serie3 = result.Series.ElementAtOrDefault(2),
         Serie4 = result.Series.ElementAtOrDefault(3)
     };
     ViewBag.players = players.Select(x => new PlayerViewModel(x))
         .ToArray();
     return View("RegisterBitsVerify", vm);
 }
 public AbsenceViewModel(Absence absence, Player player)
 {
     PlayerName = player.Name;
     From = absence.From;
     To = absence.To;
 }
 public CreatePlayerViewModel(Player player)
 {
     Name = player.Name;
     Email = player.Email;
     Status = player.PlayerStatus;
 }
Exemple #8
0
 public BitsParser(Player[] players)
 {
     if (players == null) throw new ArgumentNullException("players");
     this.players = players;
 }